Div draggable UI无法正常工作

时间:2015-04-09 10:13:47

标签: jquery jquery-ui draggable jquery-ui-draggable

<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<style>
    div{width:100px;height:100px;background:yellow;}
</style>
<script>
    $(document).ready(function(){
        $('div').draggable();
    });
</script>
</head>
<body>
<div>Drag Me</div>
</body>
</html>

代码必须提供可拖动的div&#39;使用&#39; jquery ui&#39;,但我的div不可拖动。有人能找到原因吗?

3 个答案:

答案 0 :(得分:0)

<div id="draggable" class="ui-widget-content">
  Drag Me
</div>
<script>
    $(document).ready(function(){
        $('#draggable').draggable();
    });
</script>

答案 1 :(得分:0)

工作演示

&#13;
&#13;
$(function() {
  $('div').draggable();
});
&#13;
div {
  width: 100px;
  height: 100px;
  background: yellow;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<div>Drag Me</div>
&#13;
&#13;
&#13;

答案 2 :(得分:0)

我已将您的代码测试到Chrome,它对我来说很好。 我建议你访问jquery UI示例(https://jqueryui.com/draggable/