I am trying to alternate the background colors of the rows of a table, with each section starting with the same color. I achieved this with the following code:
$(document).ready(function(){ $("tbody tr.row:nth-child(even)").css("background", "#efefef"); });
I also need to limit the number of lines (e.g. 5) that are visible inside each part of the body. They should be able to switch using the button with the .click () event. Does anyone know how I can achieve this? The only solutions I came up with were blurring the background colors. Any help would be greatly appreciated!
Here is an example table structure:
<table>
<tbody>
<tr>
<td>Cell Contents</td>
<td>Cell Contents</td>
</tr>
<tr>
<td>Cell Contents</td>
<td>Cell Contents</td>
</tr>
<tr>
<td>Cell Contents</td>
<td>Cell Contents</td>
</tr>
</tbody>
<tbody>
<tr>
<td>Cell Contents</td>
<td>Cell Contents</td>
</tr>
<tr>
<td>Cell Contents</td>
<td>Cell Contents</td>
</tr>
<tr>
<td>Cell Contents</td>
<td>Cell Contents</td>
</tr>
</tbody>
</table>
source
share