I am having trouble getting an ID of an element. The codes work in FF and chrome but not IE.
Can anyone help me about it? Thanks a lot
<td id='tdID'>
<img id='test' src='a.jpg' class='imgClass' />
</td>
jquery
$('.imgClass').click(function(){
ip=$(this).parent().attr('id');
//undefined in IE
console.log(ip);
})
<td>s must be inside a<table>. If they are not, most browsers will remove them from the DOM. So, the$(this).parent()might not be the element you think.Here’s a quick demo: http://jsfiddle.net/NTICompass/cyK3h/