Friday, 30 August 2013

get ID of Img element which is inside the td of table Using Jquery

get ID of Img element which is inside the td of table Using Jquery

I have a table in which i got the img elements in each td (table is in the
order of 2 rows and 2 Columns) i have to get the id of the image on Hover
i used the "closest" selecter in Jquery.. but not able to get the "id " of
the img which i hover
$(document).ready(function () {
$('img').closest('td').hover(function () {
var id =
$(this).parent('td').prev().children('img').attr('src').substring(0,
7);
alert(id);
});
});
Kindly help me with this issue

No comments:

Post a Comment