請看這個小提琴:http://jsfiddle.net/hvncN/ This 小提琴實現了一個簡單的拖放名單和工作正常。拖放在線工作但不在本地工作?
而且當我使用Wamp服務器本地主機運行相同的代碼時,它工作正常。 但無論如何,當我嘗試在我的筆記本電腦本地做到這一點(沒有wamp服務器),我無法做到這一點。
所以,這裏是代碼:
<HTML>
<HEAD>
</HEAD>
<BODY>
<section id="demos">
<h1>Demos</h1>
<style>
#demos section {
overflow: hidden;
}
.sortable {
width: 310px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.sortable.grid {
overflow: hidden;
}
.sortable li {
list-style: none;
border: 1px solid #CCC;
background: #F6F6F6;
color: #1C94C4;
margin: 5px;
padding: 5px;
height: 22px;
}
.sortable.grid li {
line-height: 80px;
float: left;
width: 80px;
height: 80px;
text-align: center;
}
.handle {
cursor: move;
}
.sortable.connected {
width: 200px;
min-height: 100px;
float: left;
}
li.disabled {
opacity: 0.5;
}
li.highlight {
background: #FEE25F;
}
li.sortable-placeholder {
border: 1px dashed #CCC;
background: none;
}
</style>
<section>
<h1>Sortable List</h1>
<ul id="sortable1" class="sortable list">
<li draggable="true" class style="display: list-item;">Item 1
<li draggable="true" class style="display: list-item;">Item 2
<li draggable="true">Item 3
<li draggable="true">Item 4
<li draggable="true">Item 5
<li draggable="true">Item 6
</ul>
</section>
</section>
<script src="/html5sortable/jquery-1.7.1.min.js"></script>
<script src="/html5sortable/jquery.sortable.js"></script>
<script>
$(function() {
$('#sortable1, #sortable2').sortable();
$('#sortable3').sortable({
items: ':not(.disabled)'
});
$('#sortable-with-handles').sortable({
handle: '.handle'
});
$('#sortable4, #sortable5').sortable({
connectWith: '.connected'
});
});
</script>
</BODY>
</HTML>
,這裏是在控制檯日誌中的錯誤:
Failed to load resource file:///C:/html5sortable/jquery-1.7.1.min.js
Failed to load resource file:///C:/html5sortable/jquery.sortable.js
Uncaught ReferenceError: $ is not defined
爲什麼代碼上小提琴和WAMP服務器正常工作但不是在打開時單獨如file:///C:/wamp/www/test.html
我希望它能夠t o完全離線的工作,沒有Wamp服務器,因爲我後來要把所有這些文件放到一個混合Android應用這應該是脫機工作。我該如何讓它脫機工作?
jquery文件在正確的目錄中?檢查您的瀏覽器控制檯是否存在此類錯誤 –
你是否缺少jQuery UI 1.8.18? – HICURIN
@ hanish.kh請參閱編輯的問題。 – coder