嗨,我想在Drop Event之后获得Drop目标className / ID。有人告诉我怎么弄?
<div class="drop_1" id="drop1"></div>
<div class="drop_2" id="drop2"></div>
<div class="drop_3" id="drop3"></div>
所有DIV组件都必须是可拖动的&amp;可以互相放弃
答案 0 :(得分:1)
在drop handler
中使用this.id.$( ".selector" ).droppable({
drop: function(event, ui) {
console.log(this.id);
}
});
答案 1 :(得分:0)
$(function() {
***/* Make draggable */***
$(".drop_1, .drop_2, .drop_3").draggable();
var dropOpts = {
accept:".drop_1, .drop_2, .drop_3",
drop:dropCallback,
greedy:true
};
/* Droppable */
$(".drop_1, .drop_2, .drop_3").droppable(dropOpts);
/*get your Drop target*/
function dropCallback(e) {
alert("The firing droppable was " + e.target.className);
}
});