Here is my code:
$('.canDrag').draggable({
revert:'invalid',
snap:'.dropSpace',
cursor:'move',
start:function() {
$(this).addClass('currentDrag');
}
});
This is sets the draggable elements and attaches a function to the start event.
This is the droppable code:
$('.trashSpace').droppable({
drop:function() {
$('.currentDrag').remove();
},
});
To clarify, I’m trying to make a ‘trash’ section of the document where elements disappear when dropped in. I’ve set a currentDrag class to the draggable and set the drop function to remove the currentDrag class when dropped. But the remove is not happening. Please help.
You have an extra comma in the
droppablecode.I tested the code using jQuery 1.7.1 and jQuery 1.8.13 and it is working.
HERE is the code.