这是我的 jquery 可排序代码。在将元素拖入其中后,我想从 sortable2 和 sortable3 中删除重复项。我尝试了很多方法,但我失败了。请给我一个完整的工作代码,以便我可以在我的脚本上实现它。
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Sortable - Connect lists</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<style>
#sortable1, #sortable2, #sortable3 { list-style-type: none; margin: 0; padding: 0 0 2.5em; float: left; margin-right: 10px; width: 200px; height: 200px; border: solid 1px black; }
#sortable1 li, #sortable2 li, #sortable3 li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; width: 120px; }
</style>
<script>
$(function () {
$("#sortable2").sortable({});
$("#sortable3").sortable({});
$("#sortable1").sortable({ });
$( "#sortable1 li" ).draggable({
connectToSortable: "#sortable2,#sortable3",
helper: "clone",
revert: "invalid"
});
});
</script>
</head>
<body>
<ul id="sortable1" class="connectedSortable">
<li class="ui-state-default" id="k1">Item 1</li>
<li class="ui-state-default"id="k2">Item 2</li>
<li class="ui-state-default"id="k3">Item 3</li>
<li class="ui-state-default"id="k4">Item 4</li>
<li class="ui-state-default"id="k5">Item 5</li>
</ul>
<ul id="sortable2" class="connectedSortable">
</ul>
<ul id="sortable3" class="connectedSortable">
</ul>
</body>
</html>