如何解决如何获得使用sortablejs进行排序的可排序列表的顺序?
我的代码与此类似:
new Sortable(sortablelist,{
animation: 150,ghostClass: 'sortable-ghost'
});
.box {
background-color: powderblue;
margin: 4px;
padding: 2px;
width: 25%;
cursor: move;
}
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<script src="https://raw.githack.com/SortableJS/Sortable/master/Sortable.js"></script>
</head>
<body>
<center>
<div id="sortablelist">
<div class="box" id="Item 1">Item 1</div>
<div class="box" id="Item 2">Item 2</div>
<div class="box" id="Item 3">Item 3</div>
</div>
</center>
</body>
</html>
我是初学者,希望您能帮助我。我觉得我已经搜索过孔网了。 该订单将继续保存在数据库中,但是我现在对PHP有一点经验,并且认为我可以管理它。
解决方法
如果您使用JQuery,则可以使用sortable.toArray()
。
$("#sortablelist").sortable.toArray("orderedIds");
这会将可排序的所有项目的ID放入数组。因此,在您的情况下,它将返回(如果您尚未更改订单):
["Item 1","Item 2","Item 3"]
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。