在jquery中拖放
我在另一个div上没找到掉下去的div的id 我拿到了身份证但没拿到身份证 因此,删除的警报id_未定义 请帮助我验证代码并更正错误在jquery中拖放,jquery,Jquery,我在另一个div上没找到掉下去的div的id 我拿到了身份证但没拿到身份证 因此,删除的警报id_未定义 请帮助我验证代码并更正错误 $(".full-circle").droppable({ accept: ".unseated_guest", drop: function(event, ui) { var id_droppable = this.id; alert(id_droppable); var id_dropped =
$(".full-circle").droppable({
accept: ".unseated_guest",
drop: function(event, ui) {
var id_droppable = this.id;
alert(id_droppable);
var id_dropped = ui.id;
alert(id_dropped);
var name=document.getElementById("div_name_0").value;
$(this).css("background-color","red");
$(this).append(ui.draggable);
//$(this).draggable('disable');
}
});
ui
参数没有id
属性,因为它是对正在使用的元素的引用。您需要像ui.draggable.attr('id')
一样获取id
,或者任何您希望获取元素的id
的方法
$(".full-circle").droppable({
accept: ".unseated_guest",
drop: function(event, ui) {
//Stuff above
var id_dropped = ui.draggable.attr('id');
alert(id_dropped);
//Stuff below
}
});
在拖放处理程序中,
$(this)
是可拖放的,ui.draggable
是可拖放的(作为jQuery对象)。因此,对于可拖放:
$(this).attr('id');
// or
this.id;
对于可拖动的:
ui.draggable.attr('id');
// or, for the sake of symmetry:
ui.draggable[0].id;