Corneliu
Corneliu

Reputation: 21

How to get the id of the div where I drop an element?

Let's make it useful with this link: conta.md/rafturi/kae/tester.php.

I have 2 divs (containers), one div clone draggable white background and one black div draggable that comes from mysql (let's say).

I want that when I move the black div from the curent div parent to the next one to have a variable insite stop:function that give me de id of the new div. Please show me what exactly to do. inside this stop:function I have 2 variables: one gives me the id of the current div and ones give me de id of the element I move (black div).

Upvotes: 0

Views: 1853

Answers (2)

Sean
Sean

Reputation: 75

To get the id of the dropped location where my li has an id value set so

<li id="12">---</li>

$("#sortable li").droppable({
      hoverClass: 'droparea',
       drop: 
            function( event, ui ) {
                droppedId = $( this ).attr("id");
                alert (droppedId);
            }

  });

Upvotes: 4

A. M.
A. M.

Reputation: 565

You could try something like this:

$(element).draggable({
    stop: function(event, ui) { dropElementID = $(ui.droppable).attr('id'); }   
});

Upvotes: 0

Related Questions