javascript - How to get image id using jQuery? -


i have written code this. <img id='test_img' src='../../..' />

i want id of image on image load like,

$(img).load(function() { // here want image id i.e. test_img }); 

can please me?

thanks.

$(img).load(function() {    var id = $(this).attr("id");    //etc }); 

good luck!!

edit:

   //suggested others (most efficient)    var id = this.id;     //or if want keep using object    var $img = $(this);    var id = $img.attr("id") 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -