2014-08-29 44 views
0

我以前使用过.draggable()函数,并且它以前的工作正常。但是这次它甚至没有工作。我不知道为什么?.draggable不能在div上工作

这是我的jQuery的链接

<script src="https://code.jquery.com/jquery-2.1.1.js"></script> 
<script src="https://code.jquery.com/ui/1.11.1/jquery-ui.js"></script> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> 
<link rel="stylesheet" href="https//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css"> 

这是我的HTML代码

<div class="mainArea" id="response"> 
    <div class="designer"> 
     <?php include"shirtBasic.svg" ?> 
     <div id="imageDiv"> </div> 
     <div id="dragDiv"> </div> 
    </div> 
    <table width="100%" border="0" id="sizeBar"> 
     <tr> 
      <td class="leftBarButton" style="width:50%">Front</td> 
      <td class="leftBarButton" style="width:50%">Back</td> 
     </tr> 
    </table> 
</div> 

,这是jQuery的

$(document).ready(function() { 
    $(function() { 
     $('#dragDiv').draggable(); 
    }); 
}); 

这是不是唯一的代码有HTML和jQuery之上和之下的其他代码,但不相关。

请帮我看看问题,并建议如果我已经链接了正确的jQuery版本,如果有更新的可用,请赐教。

+2

你为什么包括两个版本的jQuery? – j08691 2014-08-29 19:28:09

+0

@ j08691老实说,这些版本和他们的名字一直困惑我请指出一个删除? – 2014-08-29 19:28:59

+0

2个版本的jquery可能会导致冲突。你应该保持第一个。不要删除UI – 2014-08-29 19:29:52

回答

3

您的代码工作得很好... http://jsfiddle.net/m6ac80wb/2/

你应该只使用一个版本的jQuery。你可以保持最新的一个https://code.jquery.com/jquery-2.1.1.js

另外,不要忘记导入的jquery-ui.jsjquery-2.1.1.js

+0

Im sorry for this愚蠢的问题。所以看上面的代码我应该只保留第一个并删除第二个和第三个版本? – 2014-08-29 19:37:40

+0

@AubyBukhari第二个是UI,我会保留它(如果有效的话)。你可以删除第三个。 – 2014-08-29 19:40:49

+0

@SpencerWieczorek有没有2.1.1的UI版本? – 2014-08-29 19:42:31

1

您可以尝试使用:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css"> 
<script src="http://code.jquery.com/jquery-1.11.1.js"></script> 
<script src="http://code.jquery.com/ui/1.11.1/jquery-ui.js"></script> 
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css"> 

它的工作原理,如果你尝试这种方式,也是你的样式表是缺少“:”在URL中,这是不是它不工作的原因,但我想我应该指出。