Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 找出a可拖动部件所在的可拖放部件_Javascript_Jquery_Jquery Ui - Fatal编程技术网

Javascript 找出a可拖动部件所在的可拖放部件

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

我正在使用jQueryUI执行一些拖放操作。我想知道什么是可拖放的

有人能帮忙吗?这是我的密码

$(".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"));  
    }
});