Im trying to add a class to a TD which contains a DIV.
HTML:
<td>
<div class="report">
Some HTML
</div>
</td>
My jQuery:
开发者_开发百科$('.report').prev().addClass('wrapper');
What am I doing wrong?
$('.report').parent().addClass('wrapper');
Parent, not Prev :)
.prev()
searches only among siblings of the node, ie. nodes that reside on the same level of the DOM tree. The function you're looking for is .parent()
.
精彩评论