blue-sky
blue-sky

Reputation: 53786

Access div id within droppable

Can I access the div id of a droppable element within jQuery :

$(".all").droppable({ 
    drop: function(event, ui) { 
        // Get the droppable div id here
    }
}); 

Upvotes: 1

Views: 79

Answers (2)

ShankarSangoli
ShankarSangoli

Reputation: 69905

Inside the drop event $(this) represents the droppable element and ui.draggable represents the draggable. You can try this.

$(".all").droppable({ 
    drop: function(event, ui) { 
        alert(this.id);
    }
}); 

Upvotes: 0

Sampson
Sampson

Reputation: 268324

You can use this.id, or get that from the ui.helper:

$( ".all" ).droppable({ 
  drop: function(event, ui) { 
    alert( ui.helper.id );
  }
});

Upvotes: 2

Related Questions