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.p开发者_开发问答hp.
I have 2 div
s (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
).
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);
}
});
You could try something like this:
$(element).draggable({
stop: function(event, ui) { dropElementID = $(ui.droppable).attr('id'); }
});
精彩评论