Need Id of BOTH draggable and droppable ID's jqueryUI

核能气质少年 提交于 2019-12-13 00:49:13

问题


I can get the id of the item I have dropped on with the below code, but if i try to change the alert to get the id of the dragged item, nothing happens. e.g. alert(ui.draggable.attr('id') );

 $(function() {
             function dropCallback(e) {
              alert("The firing droppable item was " + e.target.id );
                };


        $("#draggable").draggable({axis:"x"});
         var dropOpts = {
          accept:"#draggable",
          drop:dropCallback,
          greedy:true
        };


        $(".target").droppable(dropOpts);
    }); 

回答1:


Try using...

drop:function(event,ui) {alert($(ui.draggable).attr("id"));}


来源:https://stackoverflow.com/questions/5668796/need-id-of-both-draggable-and-droppable-ids-jqueryui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!