【发布时间】:2016-09-01 11:09:00
【问题描述】:
ID 2 之前的所有tr 及其下的所有 ID 都应该是相同的颜色。检查示例。但是ID 2以后就不会变了。
这是我的代码:
[id="1"], [id="1"] ~ tr {
background-color: blue;
}
[id="2"], [id="2"] ~ tr {
background-color: red;
}
<table>
<tbody>
<tr id="1"><td>foo</td></tr> <!-- Blue -->
<tr><td>foo</td></tr> <!-- Blue -->
<tr><td>foo</td></tr> <!-- Blue -->
<tr id="2"><td>foo</td></tr> <!-- Red -->
<tr><td>foo</td></tr> <!-- Red -->
<tr id="1"><td>foo</td></tr> <!-- Blue (But is Red) -->
<tr><td>foo</td></tr> <!-- Blue (But is Red) -->
<tr><td>foo</td></tr> <!-- Blue (But is Red) -->
<tr><td>foo</td></tr> <!-- Blue (But is Red) -->
</tbody>
</table>
【问题讨论】:
-
idof element indocument应该是唯一的。
标签: jquery html css css-selectors