我正在尝试使用jQuery Sortable对项目进行排序。出于某种原因,我无法对孩子li
进行排序,只能移动和排序父li
。当我尝试移动孩子li
时,它会与父ul
$( "#list-tree-pages" ).sortable({
placeholder: "ui-state-highlight",
items: "> li",
revert: true
});
$( "#list-tree-pages" ).disableSelection();

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="parent-0 ui-sortable" id="list-tree-pages">
<li class="item-3 has-children"><a href="#" class="drag ui-sortable-handle"><i class="fa fa-bars"></i></a><a href="#">Features</a>
<ul class="submenu" id="parent-3" style="display: block;">
<li class="item-10"><a href="#" class="drag ui-sortable-handle"><i class="fa fa-bars"></i></a><a href="#">Features 1</a></li>
<li class="item-11"><a href="#" class="drag ui-sortable-handle"><i class="fa fa-bars"></i></a><a href="#">Features 2</a></li>
<li class="item-12"><a href="#" class="drag ui-sortable-handle"><i class="fa fa-bars"></i></a><a href="#">Features 3</a></li>
</ul>
</li>
</ul>
&#13;
答案 0 :(得分:0)
抱歉设法解决了这个问题。这是JavaScript参数。我必须删除>
$( "#list-tree-pages" ).sortable({
placeholder: "ui-state-highlight",
items: "li",
revert: true
});
$( "#list-tree-pages" ).disableSelection();