I have a table that looks like:
onetwothreelast< 相关标签: 2条回答 情书的邮戳 2020-12-30 20:22 Use this: $('tr td:not(:last-child)').css('background-color', 'red'); It's saying each <td> that's not the last in that particular <tr> 0 讨论(0) 发布评论: 提交评论 加载中... 梦毁少年i 2020-12-30 20:28 $('tr').find('td:not(:last)').css('background-color', 'red'); Translates to: for each element in $('tr') selector, do a find() for all tds that are not last. New result is about tds now, so you can apply .css() as wanted. 0 讨论(0) 发布评论: 提交评论 加载中... 验证码 看不清? 提交回复 热议问题
Use this:
$('tr td:not(:last-child)').css('background-color', 'red');
It's saying each <td> that's not the last in that particular <tr>
<td>
<tr>
$('tr').find('td:not(:last)').css('background-color', 'red');
Translates to: for each element in $('tr') selector, do a find() for all tds that are not last. New result is about tds now, so you can apply .css() as wanted.
$('tr')
find()
td
.css()