i have html like this, when i click on LIKE button i want to know <div id="div17836463" how could i know that?
<div class="MessageInfo">
<div id="div17836463" class="Display">Display</div>
<div class="Actions">
<span><a class="like-Unlike" href="">Like</a></span> |
</div>
</div>
please check this : http://jsfiddle.net/mHJnH/2/
Assuming
thisis a reference to theaelement:The
.closest()method climbs up the DOM tree to the first ancestor matching the selector (thedivis the grandparent of theaelement), and the.prev()method gets the immediately preceding element.