开发者

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

开发者 https://www.devze.com 2023-03-23 04:49 出处:网络
Let\'s make it useful with this link: conta.md/rafturi/kae/tester.p开发者_开发问答hp. I have 2 divs (containers), one div clone draggable white background and one black div draggable that comes from

Let's make it useful with this link: conta.md/rafturi/kae/tester.p开发者_开发问答hp.

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).


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'); }   
});
0

精彩评论

暂无评论...
验证码 换一张
取 消