Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

jQuery UI Droppable enable() Method

  • Last Updated : 28 Dec, 2021

jQuery Mobile is a set of HTML5 based user system interaction widget toolbox used for various purposes build on top of jQuery. It is designed to build fast and responsive sites accessible to mobile, tabs, and desktops. The jQuery UI Droppable enable() method is used to enable the draggable elements to be accepted by the droppable element.

Syntax:

$('selector').droppable("enable");

Parameters: This method does not accept any parameters.

 

CDN Links: First, add jQuery UI scripts needed for your project.

<link rel=”stylesheet” href=”https://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css”>
<script src=”https://code.jquery.com/jquery-1.12.4.js”></script>
<script src=”https://code.jquery.com/ui/1.12.1/jquery-ui.js”></script>

Example:

HTML




<!doctype html>
<html lang="en">
  
<head>
    <link rel="stylesheet" href=
    <script src=
    </script>
    <script src=
    </script>
    <style>
        h1 {
            color: green;
        }
  
        div {
            color: white;
            display: flex;
            justify-content: center;
            align-items: center;
            text-align: center;
        }
  
        #div2 {
            width: 150px;
            height: 150px;
            background: blue;
        }
  
        #div1 {
            position: absolute;
            left: 250px;
            width: 200px;
            height: 200px;
            background: green;
            color: #fff;
        }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
  
    <h3>jQuery UI Droppable enable() method</h3>
  
    <div id="div1">Drop here</div>
    <div id="div2">Drag me</div>
  
    <br>
    <button onclick="enableDroppable()">
      Enable Droppable
    </button>
  
    <script>
        $("#div2").draggable();
        $("#div1").droppable({
            drop: () => alert("Element Dropped!")
        });
  
        // Disable droppable by default
        $("#div1").droppable("disable");
  
        // Enab;e droppable on function call
        function enableDroppable() {
            $("#div1").droppable("enable");
        }        
    </script>
</body>
  
</html>

Output:

Reference: https://api.jqueryui.com/droppable/#method-enable


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!