Tutorials Courses Interview Prep (100 Q&A) AI Tools (50) Developer Tools (50) Tracks Pricing Plans Blog & Articles Contact Us
Interactions & Widgets 14 mins read Free Lesson

jQuery UI Setup & Drag-and-Drop Interactions

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>