Thursday, May 07, 2009

Alternate table row color using javascript

This version on javascript has been tested on Firefox, Safari, IE 6, and IE7

$('chart_table').select("tbody tr").each( function(e) {
Event.observe(e, 'mouseover', function() {
Element.addClassName(e, 'hover');
});
Event.observe(e, 'mouseout', function() {
Element.removeClassName(e, 'hover');
});
});


========css =====
.hover{ background-color:#CECECE; color: #fff;}


More detail:
http://www.sidesofmarch.com/index.php/archive/2007/04/23/an-ie6-compatible-solution-for-hover/