Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

datatables jquery - alternate colors for the rows

I have used datatables jquery in my application. When I used datatables jquery to set alternate colors for my rows, I faced a issue. That is, in a table 2nd,3rd,4th,5th n 6th row are all displayed in same color and after that colors are displayed alternately. Could anyone help me with this? Thanks in advance.

My code in jquery.datatables.css :

table.dataTable tr.odd { background-color:  red; }
table.dataTable tr.even { background-color: green;  }

I have attached the screenshot of the table.

enter image description here

When I checked, every row is having either class="even" or class="odd" but the 2nd,3rd,4th,5th,6th rows are having class="odd even". I dont know why it is like this.

like image 706
kishore Avatar asked Feb 16 '23 03:02

kishore


1 Answers

Found the answer :

table.dataTable tr{ background-color:  red; }
table.dataTable tr:nth-child(even)  { background-color: green;  }
like image 72
kishore Avatar answered Feb 27 '23 22:02

kishore