Reputation: 13843
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?
Upvotes: 0
Views: 125
Reputation: 5888
.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()
.
Upvotes: 2
Reputation: 1008
$('.report').parent().addClass('wrapper');
Parent, not Prev :)
Upvotes: 4