Javascript 找出a可拖动部件所在的可拖放部件
我正在使用jQueryUI执行一些拖放操作。我想知道什么是可拖放的 有人能帮忙吗?这是我的密码Javascript 找出a可拖动部件所在的可拖放部件,javascript,jquery,jquery-ui,Javascript,Jquery,Jquery Ui,我正在使用jQueryUI执行一些拖放操作。我想知道什么是可拖放的 有人能帮忙吗?这是我的密码 $(".draggable").draggable({ stop: function(event, ui){ console.log(event); // I need the element which this draggable is correct in. } }); 我想你需要在droppables drop回调中捕捉到这一点 $('#dra
$(".draggable").draggable({
stop: function(event, ui){
console.log(event);
// I need the element which this draggable is correct in.
}
});
我想你需要在droppables drop回调中捕捉到这一点
$('#draggable').draggable();
$('#droppable').droppable({
drop: function( event, ui ) {
alert($(this).attr("id"));
}
});
下面我们来看看这把小提琴,可以用来摆弄它:
编辑:哦,这是被拖动元素的id!你想要它降落的地方!这很容易!我编辑了答案中的脚本以显示这一点
查看可拖动和可拖放文档,了解有关其工作原理的更多信息:
我想您需要在droppables drop回调中捕捉到这一点
$('#draggable').draggable();
$('#droppable').droppable({
drop: function( event, ui ) {
alert($(this).attr("id"));
}
});
下面我们来看看这把小提琴,可以用来摆弄它:
编辑:哦,这是被拖动元素的id!你想要它降落的地方!这很容易!我编辑了答案中的脚本以显示这一点
查看可拖动和可拖放文档,了解有关其工作原理的更多信息:
我认为@Patricia的做法有点不对。我用了他们的JSFIDLE,但本质是将项目的id放入
$('.droppable').droppable({
drop: function( event, ui ) {
alert($(this).attr("id"));
}
});
我认为@Patricia的说法有点不对。我用了他们的JSFIDLE,但本质是将项目的id放入
$('.droppable').droppable({
drop: function( event, ui ) {
alert($(this).attr("id"));
}
});