Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery datatable with tri color rows

I tried jquery datatable with tri colored rows which is repeating alternatively.But i got only two colored rows repeating.

Tried jquery datatable with tri colored rows
I'm using property even/odd for coloring

$(document).ready(function() {
    $('#example').dataTable();
} );
$(document).ready(function() {
 $("#example tr:even").css("background-color", "LightYellow");
 $("#example tr:odd").css("background-color", "LightBlue");
});
like image 237
SAJINA C Avatar asked Feb 19 '15 09:02

SAJINA C


1 Answers

You don't have to use jquery to implement this CSS is much suitable for that job. try this.

/*tri color rows*/
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;
}
/* End: tri color rows*/

check this Demo in js fiddle

like image 121
tvshajeer Avatar answered Nov 04 '22 01:11

tvshajeer