Looking for a solution to alternate colors in a table? Here's what I tried:
#grid tr:nth-child(odd) { background-color:#eee; }
#grid tr:nth-child(even) { background-color:#fff; }
Unfortunately, this works in Firefox but not in IE8. After some investigation, I attempted the following:
CSS:
#grid tr.odd { background-color:#eee; }
#grid tr.even { background-color:#fff; }
jQuery:
$(document).ready(function() {
$("#grid tr:nth-child(even)").addClass("even");
$("#grid tr:nth-child(odd)").addClass("odd");
});
However, this approach didn't work as expected (not even in Firefox). Open to suggestions on how to solve this issue without resorting to using third-party JavaScript libraries like Selectivizr.
Appreciate any help, thank you!