这个是js代码主要在js代码中红色代码部分设置了可以拖动进入时就排序,橙色代码部分不太理解,好像没用的样子 复制代码 代码如下: $(function () { $("#catalog").accordion(); $("#catalog li").draggable({ appendTo: "body", helper: "clone", connectToSortable: "#cart ol" }); $("#cart ol").sortable({ items: "li:not(.placeholder)", connectWith: "li", sort: function () { $(this).removeClass("ui-state-default"); }, over: function () { //hides the placeholder when the item is over the sortable $(".placeholder").hide(); }, out: function () { if ($(this).children(":not(.placeholder)").length == 0) { //shows the placeholder again if there are no items in the list $(".placeholder").show(); } } }); });