开发者

jQuery :last-child selector

开发者 https://www.devze.com 2022-12-25 18:40 出处:网络
How do I add class=\"x\" to the last table cell that\'s on the same row as the one that has class=\"insert\"开发者_C百科?

How do I add class="x" to the last table cell that's on the same row as the one that has class="insert"开发者_C百科? Something like:

$('td.insert').parents('tr').(':last-child').addClass('x');


You can do that like this:

$('td.insert').siblings(':last-child').addClass('x');

This filters the sibling cells, leaving only the last child to add the class to.


$('td.insert').siblings(':last-child').addClass('x');
0

精彩评论

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

关注公众号