开发者

Get id of div where i drag an element

开发者 https://www.devze.com 2023-03-23 10:45 出处:网络
I have 2 or more divs droppable and a place where a have some products that i drag&drop into this 2 or more divs.

I have 2 or more divs droppable and a place where a have some products that i drag&drop into this 2 or more divs. After a drop an element in one of the divs i want to move that element in other div drippable and whant to know what's that div id.

I search on google and i found this : - $(event.target).attr("id") - this one give me the id of the element that i move - 开发者_如何学JAVA$(this).parent().attr('id') - this one give me the id of the div container where my element was

After i move the element i want to know the id of the div where i drop the element.


You can access the id of the draggable and droppable in the drop callback function - see this demo

Taking @jensgram's advice (Utilizing the awesome power of jQuery to access properties of an element) for speed of this.id over .attr('id')


try this--

$('#droppable').droppable({
   drop: function() {
     $(this).attr('id');
   }
});

and have a look at this post- some info about drag and drop

0

精彩评论

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