<table id="tab">
<tr> <td>11</td> <td>22</td> </tr>
<tr> <td>33</td> <td>44</td> </tr>
<tr> <td>55</td> <td>66</td> </tr>
</table>
#tab td {
border: solid 2px red;
padding: 10px;
}
#tab td {
background-color: green;
}
我希望只有在上一个 TR TD 是绿色的 - 55 和 66。 11、22、33、44 的 TD 必须是白色。
我用 PHP 生成这个表 - 我必须只使用 CSS 或 jQuery。
#tab td:last {
background-color: green;
}
不起作用。
最佳答案
符合标准的解决方案是:
#tab tr:last-child td {
background-color: green;
}
但是它在 IE6-8 中不受支持。 Fot 他们你可以使用 jQuery 片段:
$(function(){
$('#tab tr:last td').css('background', 'green');
});
关于javascript - 选项卡中的 CSS - 最后一个 TR TD,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7794675/