You do not need to use jquery to implement this CSS, which is very suitable for this job. try it.
table.dataTable tbody tr:nth-child(3n+1) {background-color: #FFCCCC;} table.dataTable tbody tr:nth-child(3n+2) {background-color: #99D6AD;} table.dataTable tbody tr:nth-child(3n) {background-color: #EBD6FF;} th { background: #aaf; } thead{ background: #aaf; }
check this demo in js fiddle
source share