开发者

jQuery how to find the class of the Droppable Div?

开发者 https://www.devze.com 2023-01-09 21:29 出处:网络
I have two divs: one draggable and one droppable <div id=\"draggable\" class=\"block\" runat=\"server\">

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.


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...

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

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

Which gives you the behaviour you are after (i.e. you can only drop on a droppable).

0

精彩评论

暂无评论...
验证码 换一张
取 消