Open In App

jQuery UI Droppable disabled Option

jQuery Mobile is a web-based technology that is used to make responsive content for websites that can be accessed on all types of smartphones, tablets, and desktops. In this article, we will be using the jQuery Mobile Droppable disabled Option to disable the droppable if set to true. and this also accepts boolean parameters.

Syntax: The disabled option takes a boolean value and the syntax is as follows. If true, we can disable the panel and vice-versa.



$("#selector").droppable({
    disabled: true
});

CDN Link: Below are some jQuery Mobile scripts that will be needed for your project so add these to your project.

<link href = “https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css” rel = “stylesheet”>
<script src = “https://code.jquery.com/jquery-1.10.2.js”></script>
<script src = “https://code.jquery.com/ui/1.10.4/jquery-ui.js”></script>

Example: This example describes the uses of the jQuery Mobile Droppable disabled Option.




<!DOCTYPE html>
<html lang="en">
  
<head>
    <link rel="stylesheet" href=
    <script src=
    </script>
    <script src=
    </script>
  
    <style>
        .dragg {
            width: 90px;
            height: 50px;
            border: 1px solid black;
            background-color: blue;
        }
  
        .dropp2,
        .dropp3 {
            width: 200px;
            height: 50px;
            border: 1px solid black;
            float: center;
            background-color: green;
        }
    </style>
  
    <script>
        $(function () {
            $(".dragg").draggable();
            $(".dropp2").droppable({
                drop: function (event, ui) {
                    $(this)
                        .find("p")
                        .html("Dropped!");
                }
            });
  
            $(".dropp3").droppable({
                disabled: true
            });
  
            $(".dropp3").droppable({
                drop: function (event, ui) {
                    $(this)
                        .find("p")
                        .html("Dropped!");
                }
            });
        });
    </script>
</head>
  
<body>
    <center>
        <h1 style="color:green;">GeeksforGeeks</h1>
  
        <h3>jQuery UI Droppable disabled Option</h3>
  
        <div class="dragg">
            <p>Drag</p>
  
        </div>
        <br><br>
        <div class="dropp2">
            <p>Drop here</p>
  
        </div>
        <br><br>
        <div class="dropp3">
            <p>Disable - Can't Drop Here</p>
  
        </div>
    </center>
</body>
  
</html>

Output:

jQuery UI Droppable disabled Option

Reference: https://api.jqueryui.com/droppable/#option-disabled


Article Tags :