这个jQUery UI draggables
样本名称Default
说:
在任何DOM元素上启用可拖动的功能。
但是,我无法让他们的工作button
。
我修改了这个Default
例子,看起来像这样:
我只是将div元素更改为一个按钮type="button"
:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Draggable - Default functionality</title>
<link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
<script src="../../jquery-1.9.1.js"></script>
<script src="../../ui/jquery.ui.core.js"></script>
<script src="../../ui/jquery.ui.widget.js"></script>
<script src="../../ui/jquery.ui.mouse.js"></script>
<script src="../../ui/jquery.ui.draggable.js"></script>
<link rel="stylesheet" href="../demos.css">
<style>
#draggable { width: 150px; height: 150px; padding: 0.5em; }
</style>
<script>
$(function() {
$( "#draggable" ).draggable();
});
</script>
</head>
<body>
<button type="button" id="draggable" class="ui-widget-content">
<p>Drag me around</p>
</button>
<div class="demo-description">
<p>Enable draggable functionality on any DOM element. Move the draggable object by clicking on it with the mouse and dragging it anywhere within the viewport.</p>
</div>
</body>
</html>
我如何使拖动功能在按钮元素上工作?
发布于 2018-02-07 13:39:27
使用cancel: false
$(function() {
$( "#draggable" ).draggable({
cancel: false
});
});
https://stackoverflow.com/questions/-100003469
复制相似问题