简体   繁体   中英

Combining revert with jQuery draggable/droppable

I'm using the drag and drop plugin with jQuery UI. I'd like to make it so that the draggable container can only be dragged and dropped on the container. In the demonstration:

http://jqueryui.com/demos/droppable/#revert

It has 2 options. One is to revert when it drags to the container, the second is to revert when it isn't dragged to the container.

Is there a way to combine these two? I don't want to be able to drag the #draggable container anywhere where there isn't a #droppable container.

As stated above, I found the solution by adding :

$('#draggable2').remove(); 
$('#draggable').draggable({ revert: true });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM