jQuery如何找到Droppable Div的类?
我有两个 div:一个是可拖动的,一个是可放置的。
<div id="draggable" class="block" runat="server">
</div>
<div id="dd" class="drop" title="drophere">
</div>
当我释放可拖动的 div 时,我想找到它的父级的类,以便在将其放置在可放置的 div 上时采取操作,否则取消拖动。
我想在draggable的停止函数中添加一个条件,如果它被放置在类为“drop”的div上,那么就可以了,否则取消拖动操作
执行此操作的函数是什么?
谢谢。
I have two divs: one draggable and one droppable
<div id="draggable" class="block" runat="server">
</div>
<div id="dd" class="drop" title="drophere">
</div>
When I release the draggable div I want to find the class of it's parent to take an action if it is dropped on a droppable div, otherwise cancel the dragging.
I want to put a condition in the stop function of the draggable that if it's dropped on a div with class "drop" then it's ok, otherwise cancel the drag operation
What can be the function that performs this ?
thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
谢谢大家
我在这个链接得到了它
http://jqueryui.com/demos/droppable/#revert
这使得 div 恢复如果没有掉落在可掉落物上。
Thanks All
I got it at this link
http://jqueryui.com/demos/droppable/#revert
this makes the div reverts if not dropped on a droppable.
通常,您可以通过使用可拖动和可放置的插件来完成此操作,如下所示...
这将为您提供所需的行为(即您只能放置在可放置的对象上)。
Normally you would do this by using the draggable and droppable plugins like this...
Which gives you the behaviour you are after (i.e. you can only drop on a droppable).