I'm looking for a CSS selector that counts every other child of its parent, but excluding certain elements from the counting. I see that the examples I came up with don't select the row marked as .ignore
, but they still count them.
Is there a CSS-way to select and count only the .normal
elements?
/* trying to exclude .ignore from the set doesn't work */
tr:not(.ignore):nth-child(even) {
background: red;
}
/* neither does filtering by .normal before applying nth-child */
tr.normal:nth-child(even) {
background: red;
}
<table>
<tbody>
<tr class="normal"><td>text</td></tr>
<tr class="normal"><td>text to be highlighted</td></tr>
<tr class="normal"><td>text</td></tr>
<tr class="ignore"><td>don't count this row</td></tr>
<tr class="normal"><td>text to be highlighted</td></tr>
<tr class="normal"><td>text</td></tr>
</tbody>
</table>