drag element to specific div
-
09-10-2019 - |
Question
want to drag element to specific div and if not dragged to this div will comeback (revert) using jQuery UI
Solution
<div id="draggable" style="width: 50px; height: 50px; border: solid 1px #000;">Drag me!</div>
<div id="droppable" style="width: 150px; height: 150px; border: solid 1px #000;">Drop here!</div>
<script type="text/javascript">
$( "#draggable" ).draggable({ revert: true });
$( "#droppable" ).droppable({
accept: "#draggable",
drop: function( event, ui ) {
// the draggable is dropped
}
});
</script>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow