我有拖放功能,我拖动div并动态放置在可放置区域。 我在可放置区域有可排序的功能, 所以我想找出索引,以便在排序后我必须找出特定div的确切索引位置。 这是我的代码
$('#workArea').sortable({cancel: ':input,button,.common'});
$(".drags").draggable({
helper : "clone",
connectWith: '.workArea'
});
$(".workArea").droppable({
drop: function( event, ui ) {
function createHead(workspace){
var head = document.createElement("div");
}
// [editor] i think i am missing a } here or pasted something wrong
});
答案 0 :(得分:0)
答案 1 :(得分:0)
在我看来,返回新索引的最佳位置将是通过排序功能。
更新全局数组中的索引可能也会有所帮助。然后在调用排序函数后在数组中搜索特定的div元素。
在JS中你总是可以使用this.target是你要删除的元素然后使用
$(this.target).index()并用$(“#parentContainer div:eq(”+ newIndex +“)”)找到它。)
希望这有帮助。