Wednesday, 11 September 2013

Alternate background color for rows

Alternate background color for rows

I am working on alternate background color and facing some challenges. I
want to set alternate background color only to ODD rows by CSS or
JavaScript/jQuery. In fiddle, I have intentionally hided the EVEN rows,
because the requirement is the same. I was trying to achieve it using
jQuery but not able to proceed further. And please guys don't suggest me
to replace the TABLE with DIV. Unfortunately I am working on old
markup(Intranet website). Help/guidance would be appreciated for existing
HTML markup.
if($('table tr').hasClass('odd')){
$(this).find('td :first-child').css('background','yellow');
}
JSFiddle

No comments:

Post a Comment