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
Post a Comment