0
Tutorial for HTML5 drag&drop - sortable list拖放的Javascript不工作的移動設備
但腳本不工作在移動設備上。我曾嘗試sortable.js和插件。所有這些都不適用於項目。這幫助了我。但是,移動設備正在
<ul>
<li draggable="true" ondragenter="dragenter(event)" ondragstart="dragstart(event)">Apples</li>
<li draggable="true" ondragenter="dragenter(event)" ondragstart="dragstart(event)">Oranges</li>
<li draggable="true" ondragenter="dragenter(event)" ondragstart="dragstart(event)">Bananas</li>
<li draggable="true" ondragenter="dragenter(event)" ondragstart="dragstart(event)">Strawberries</li>
</ul>
<script type="text/javascript">
var source;
function isbefore(a, b) {
if (a.parentNode == b.parentNode) {
for (var cur = a; cur; cur = cur.previousSibling) {
if (cur === b) {
return true;
}
}
}
return false;
}
function dragenter(e) {
if (isbefore(source, e.target)) {
e.target.parentNode.insertBefore(source, e.target);
}
else {
e.target.parentNode.insertBefore(source, e.target.nextSibling);
}
}
function dragstart(e) {
source = e.target;
e.dataTransfer.effectAllowed = 'move';
}
</script>
你應該嘗試[jQuery的觸摸衝牀(http://touchpunch.furf.com/)它是爲這個只發。 –
@SorangwalaAbbasali只爲可拖動?其餘的這些js會工作嗎? – Crock
@SorangwalaAbbasali我不確定.. jquery touch punch只支持jQuery ui的拖拽..盡我所知.. –