jQuery UI的Droppable destroy()方法

jQuery UI的Droppable destroy()方法

jQuery Mobile是一种基于网络的技术,用于为网站制作可在所有类型的智能手机、平板电脑和桌面上访问的响应式内容。

在这篇文章中,我们将使用jQuery Mobile Droppable destroy()方法来完全移除widget中的droppable功能。这个方法将元素返回到它的预启动状态,而且不接受任何参数。

语法:

$(".selector").droppable("destroy");

参数:该方法不接受任何参数。

返回值:该方法销毁了该小组件。

CDN链接:下面是一些jQuery Mobile脚本,你的项目将需要这些脚本,所以要把它们添加到你的项目中。

<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>

例子:这个例子描述了jQuery Mobile Droppable destroy()方法的用途。

<!DOCTYPE html>
<html lang="en">
  
<head>
    <link rel="stylesheet" href=
"https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css">
    <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>
  
    <style>
        .dragg {
            width: 90px;
            height: 50px;
            border: 1px solid black;
            background-color: blue;
        }
  
        .dropp {
            width: 100px;
            height: 90px;
            border: 1px solid black;
            background-color: green;
        }
    </style>
  
    <script>
        (function () {
            ('.dragg').draggable({ revert: true });
            ('.dropp').droppable({
                hoverClass: 'active',
                drop: function (e, ui) {
                    (this).html(ui.draggable.remove().html());
                    (this).droppable('destroy');
                    (this)
                        .find("p")
                        .html("Destroy Method Worked");
                }
            });
        });
    </script>
</head>
  
<body>
    <center>
        <h1 style="color:green;">
          GeeksforGeeks
        </h1>
        <h3>jQuery UI Droppable destroy() method</h3>
        <div class="dragg">
            <p>Drag</p>
  
        </div>
        <br><br>
        <div class="dropp">Drop</div>
    </center>
</body>
  
</html>

输出:

jQuery UI的Droppable destroy()方法

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程