Reputation:
i have many dragged div. is there is any way to get the id of the dragged div while dragging.
$(".table_div").draggable({
drag: function() {
var offset = $(this).offset();
$(this).html(offset.left + ', ' + offset.top);
}
});
i am using jQuery Draggable
Upvotes: 3
Views: 134
Reputation: 236162
this
is always referenced to the DOM element
of invocation.
So you can access this.id
to get the current ID.
update
You have a read Why do I have to use $(this)?
this
is a reference to your DOM element
(a div)
$(this)
is an object
, created by the jQuery constructor $ function
. You could also access the id by calling $(this)[0].id
. But that would be unnecesary work obv.
Upvotes: 3