开发者

Get id of div where i drag an element

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜