I have the following HTML:
<table id="price-table">
<tr><th>Price</th><th>Value</th></tr>
<tr class="price-row">
<td>0</td>
<td>1</td>
</tr>
<tr><th>Price</th><th>Value</th></tr>
<tr class="price-row">
<td>1</td>
<td>2</td>
</tr>
</table>
I am trying to style every odd row with the class price-row using the following:
#price-table tr.price-row:nth-child(odd) {
color: green;
}
And every even row using:
#price-table tr.price-row:nth-child(even) {
color: blue;
}
However only the even rows are being styled, and the odd rows are being completely ignored. I don't understand why this is? Doesn't the first row have the id of 1 which would be styled as odd, and the second row have an id of 2 being styled as even?
I should mention that I do expect for this table to be expandable such that further rows are able to be added and correctly styled.
Very confused I have no idea what else to try, this doesn't seem complicated unless I'm making a very silly mistake.
Edit full HTML:
<table id="price-table">
<tr>
<th>Price</th>
<th>Value</th>
</tr>
<tr class="price-row">
<td>0</td>
<td>1</td>
</tr>
<tr>
<th>Price</th>
<th>Value</th>
</tr>
<tr class="price-row">
<td>1</td>
<td>2</td>
</tr>
<tr>
<th>Price</th>
<th>Value</th>
</tr>
<tr class="price-row">
<td>0</td>
<td>1</td>
</tr>
<tr>
<th>Price</th>
<th>Value</th>
</tr>
<tr class="price-row">
<td>1</td>
<td>2</td>
</tr>
</table>