0

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.

4

2 回答 2

1

谢谢大家

我在这个链接 http://jqueryui.com/demos/droppable/#revert

如果没有放在可放置的对象上,这会使 div 恢复。

于 2010-07-29T07:41:50.360 回答
0

通常你会通过使用像这样的可拖动和可放置插件来做到这一点......

$(".block").draggable();

$(".drop").droppable();

这为您提供了您所追求的行为(即您只能放在可放置的物品上)。

于 2010-07-29T07:12:56.980 回答