jQuery.sortable.通过JavaScript更改顺序 [英] jQuery.sortable. change the order by JavaScript
本文介绍了jQuery.sortable.通过JavaScript更改顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
一旦被JavaScript jQuery.sortable
应用后,如何更改列表的顺序.
How can I change the order of a list once applied by JavaScript jQuery.sortable
.
例如:
<ul id="mylist">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
var x_sortable_list = $("mylist").sortable();
然后,假设这可行:
x_sortable_list.changeOrder([
{item:1, newOrder:2 },
{item:2, newOrder:1 },
{item:3, newOrder:3 }
]);
推荐答案
正如Sparr所说,无法直接使用sortable
对它们进行排序,但是您仍然可以使用类似以下的方法手动移动它们:
As Sparr has said, there's no way to sort them using sortable
directly, but you can still move them manually with something like:
$("#mylist li:eq(1)").insertAfter($("#mylist li:eq(2)"));
这篇关于jQuery.sortable.通过JavaScript更改顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文