Is it possible to change row colors in a table every x rows, instead of every single row?
For example, here is what the alternating rows could look like when changing every 2 rows: JSFiddle
The structure of the HTML table would be something similar to this:
<table>
...
<tr>
<td>content</td>
<td>more content</td>
</tr>
...
</table>
In my current solution, I am using a class for the tr
's that should be altered. However, I am looking for a more general approach, possibly utilizing the nth-child
selector or a similar method.
Does anyone know of an easy way to achieve this, allowing for variable intervals between altering rows (e.g. every 2 rows, 3 rows, 4 rows, etc.)? Ideally, I would prefer not to manually add class names as the table may be created dynamically and modifying the code might not be feasible.