Drop able
优质
小牛编辑
134浏览
2023-12-01
描述 (Description)
Drop-able函数可以与JqueryUI中的交互一起使用。此函数可以在任何DOM元素上启用可删除功能。我们可以通过鼠标单击它来删除可拖动元素。
语法 (Syntax)
以下是使用可拖动的简单语法 -
$( "#droppable" ).droppable();
例子 (Example)
以下是一个简单的示例,显示了drop-able的用法 -
<html>
<head>
<title>The jQuery Example</title>
<script type = "text/javascript"
src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
</script>
<script type = "text/javascript"
src = "https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.3/jquery-ui.min.js">
</script>
<script type = "text/javascript" language = "javascript">
$(function() {
$( "#draggable" ).draggable();
$( "#droppable" ).droppable({
drop: function( event, ui ) {
$( this ).addClass( "ui-state-highlight" ).find( "p" ).html( "Dropped!" );
}
});
});
</script>
<style>
#draggable { width: 100px; height: 100px;
padding: 0.5em; float: left; margin: 10px 10px 10px 0; }
#droppable { width: 150px; height: 150px;
padding: 0.5em; float: left; margin: 10px; }
</style>
</head>
<body>
<div id = "draggable" class = "ui-widget-content">
<p>Drag</p>
</div>
<div id = "droppable" class = "ui-widget-header">
<p style = "background-color: aquamarine;height: 50;">Drop here</p>
</div>
</body>
</html>