tags:

views:

32

answers:

1

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

+4  A: 

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 http://stackoverflow.com/questions/3316113/why-do-i-have-to-use-this/3316131#3316131

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.

jAndy
thanks jAndyi tryed with $(this).id it is resulted as undefined can you differ $(this).id and this.idplease because i am a beginner
shahul
@shahul: updated.
jAndy
k thnk u for valuable information
shahul