Need Id of BOTH draggable and droppable ID's j

2019-08-03 23:39发布

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条回答
兄弟一词,经得起流年.
2楼-- · 2019-08-04 00:14

Try using...

drop:function(event,ui) {alert($(ui.draggable).attr("id"));}
查看更多
登录 后发表回答