jQuery Droppable, get the element dropped

后端 未结 1 1543
挽巷
挽巷 2020-12-13 17:02

A small question hopefully with a simple answer, I am using jQuery draggable and droppable to place items into a dock. Using the below code for the drop.

$(\         


        
相关标签:
1条回答
  • 2020-12-13 17:48

    From the drop event documentation:

    This event is triggered when an accepted draggable is dropped 'over' (within the tolerance of) this droppable. In the callback, $(this) represents the droppable the draggable is dropped on. ui.draggable represents the draggable.

    So:

    $("#dock").droppable({
         drop: function(event, ui) {
                   // do something with the dock
                   $(this).doSomething();
    
                   // do something with the draggable item
                   $(ui.draggable).doSomething();
               }
    });
    
    0 讨论(0)
提交回复
热议问题