我创建了一个 jquery 可拖动的示例,
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.container{
width:400px;
height:200px;
border:1px solid red;
}
#draggable{
width: 100px;
height: 50px;
}
</style>
<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>
<script type="text/javascript">
$( "#draggable" ).draggable({
containment: ".container"
});
</script>
</head>
<body>
<div class="container">
<div id="draggable" class="ui-widget-content">
<p>Drag me around</p>
</div>
</div>
<input type= "button" value="toggle containment" id="buttonContain">
</body>
</html>
其中,我可以在添加 jQuery 可拖动小部件后删除 jQuery 可拖动包含选项吗? 请帮忙
您可以使用
$("#draggable").draggable('disable');
对于禁用和
$("#draggable").draggable('enable');
对于按钮启用,请单击