how to revert position of a jquery UI draggable based on condition
There are some built-in options for this, on your .draggable(), set the revert option to ‘invalid’, and it’ll go back if it wasn’t successfully dropped onto a droppable, like this: $(“#draggable”).draggable({ revert: ‘invalid’ }); Then in your .droppable() set what’s valid for a drop using the accept option, for example: $(“#droppable”).droppable({ accept: ‘#draggable’ }); Anything … Read more