Debug School

rakesh kumar
rakesh kumar

Posted on

Implement drag and droppable functionality in jquery

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Drag and Drop Example</title>
    <link rel="stylesheet" href="//">
    <script src=""></script>
    <script src=""></script>
        #todo, #inprogress {
            min-height: 100px;
            border: 1px solid #ddd;
            margin: 10px;
            padding: 10px;
            float: left;
        .card {
            padding: 10px;
            margin: 5px;
            cursor: move;
            background-color: #f0f0f0;

<div id="todo" class="container">
    <div class="card" id="task1">Task 1</div>
    <div class="card" id="task2">Task 2</div>
    <!-- Add more cards for your "To-Do" list -->

<div id="inprogress" class="container">
    <!-- "In Progress" cards will be added here -->

    $(document).ready(function() {
            revert: "invalid",
            helper: "clone",
            cursor: "move"

            accept: ".card",
            drop: function(event, ui) {
                var droppedCard = $(ui.helper).clone();

Enter fullscreen mode Exit fullscreen mode

This code sets up a simple HTML structure with two containers ("To-Do" and "In Progress") and uses jQuery UI for drag-and-drop functionality. The .draggable() function is applied to the cards, and the revert, helper, and cursor options are specified. The #inprogress container is set as droppable using .droppable(), specifying that it accepts cards with the class .card. When a card is dropped into the "In Progress" container, a clone of the card is created and appended to the container.


Top comments (0)