2014-08-29 121 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中,這是不是它不工作的原因,但我想我應該指出。