I need to apply background color to the alternating rows of my html table.
My current code:
.licList
{
width: 100%;
border: 1px solid #f7f7f7;
text-align: center;
border-collapse: collapse;
}
.licList th
{
font-weight: bold;
background-color: #dbdbdb;
border-bottom: 1px solid #f1f1f1;
padding: 4px 5px;
}
.licList td
{
padding: 4px 5px;
}
.odd
{
background-color: #ffffff;
}
.odd td
{
border-bottom: 1px solid #cef;
}
and jquery is
$(document).ready(function () {
$("licList:tr:odd").addClass("odd");
});
I’m sure that the above jquery is not correct I’ve multiple tables in single page so I can’t apply
$(document).ready(function(){
$("tr:odd").addClass("odd");
});
so my question is how to solve this problem????
Assign a
id/classto your table and access rows under that table. Suppose your table has id tblLive Demo