开发者

Add class to DIV with TD Wrapping

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().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜