我有一个对象列表,它分为两个容器,我想通过 jQuery 对其进行排序,但我不知道如何使一个对象能够添加到另一个容器列表中,反之亦然。因此,我希望能够将一个对象从一个容器拖到另一个容器中,并让代码将其视为一个列表。
下面是我的代码:
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Untitled 1</title>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery-ui/js/jquery-ui-1.8.22.custom.min.js"</script>
<link type="text/css" href="jquery-ui/css/smoothness/jquery-ui-1.8.22.custom.css" rel="stylesheet" />
<script type="text/javascript">
$(document).ready(function(){
$("#nowplaying_list, #nowplaying_history").sortable().disableSelection();
});
</script>
</head>
<body>
<div id="left_content" class="ui-droppable">
<div id="nowplaying_container" style="display:block;">
<div id="nowplaying_wrapper">
<div id="nowplaying_history" class="ui-sortable">
<div class="object_container ui-draggable" >OBJECT 1</div>
<div class="object_container ui-draggable" >OBJECT 2</div>
<div class="object_container ui-draggable" >OBJECT 3</div>
</div>
<div id="nowplaying_list" class="ui-sortable">
<div class="object_container ui-draggable" >OBJECT 4</div>
<div class="object_container ui-draggable" >OBJECT 5</div>
<div class="object_container ui-draggable" >OBJECT 6</div>
</div>
</div>
</div>
</div>
</body>
</html>