我正在开发一个拖放应用程序。我有一个可以沿着文档拖动的 DIV,并且文档中还有一些其他的 div,我可以将一个 div 拖到其他 div,但是如何找到我将拖动的 DIV 拖放到的 div 的 id,
我只想知道在放置另一个 DIV 之后目标 DIV 的 ID。
谢谢
最佳答案
您应该能够从事件函数 (demo) 中的 this.id
获取目标的 ID
$(".droppable").droppable({
drop: function(event, ui) {
$(this).addClass("ui-state-highlight").find("p").html("Dropped in " + this.id);
},
over: function(event, ui) {
$('.display').html( this.id );
}
});
Updated demo明确 this.id
适用于任何事件。
关于javascript - jQuery : drag and drop : find the id of the target,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3943868/