开发者

Add class to DIV with TD Wrapping

开发者 https://www.devze.com 2023-02-11 11:24 出处:网络
Im trying to add a class to a TD which contains a DIV. HTML: <td> <div class=\"report\"> Some HTML

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

精彩评论

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