Interactions & Widgets
14 mins read
Free Lesson
Setup jQuery UI CSS and JS dependencies and implement .draggable() and .droppable() interactions.
Drag-and-Drop with jQuery UI
<div id="draggable-card" class="ui-widget-content">
<p>Drag me around</p>
</div>
<div id="drop-target" class="ui-widget-header">
<p>Drop here</p>
</div>
<script>
$("#draggable-card").draggable({ revert: "invalid" });
$("#drop-target").droppable({
drop: function(event, ui) {
$(this).addClass("ui-state-highlight").find("p").html("Dropped Successfully!");
}
});
</script>