Assuming the parent div
you mention is droppable, you can bind the event handler to the dropout
event:
$("#parentDiv").on("dropout", function(event, ui) {
The event will fire at any time when an accepted drag is dragged outside the droppable tolerance area.
Refresh (see comments)
You can provide a callback function to the revert
option. The function can take one argument, which either contains droppable, to which draggable was dropped, or false
(if it was deleted somewhere invalid):
$("#draggable").draggable({ revert: function(valid) { if(!valid) {
Here is a working example .
source share