i am using this css code:
.even{
background: #E4ECF6;
}
.odd{
background: #F3F7FB;
}
.firstrow{
background-color: #599ECF;
}
i am using this css jquery code:
$(document).ready(function(){
$('table tr:even').addClass('even');
$('table tr:odd').addClass('odd');
$('table tr:first').addClass('firstrow');
});
this code run correctly for first table. but when i have two or higher table ,this code can coloring first row of first table. is better code for coloring all first rows in all tables?
Try replacing
with
The key is to use the
:first-childselector, whichLive demo here.
In case you still want to the
:firstselector, you can do it like this:Live demo here.