问题描述
我的代码与此类似:
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"]