Эта задача уже многими была решена...
function zebraTable(id, c1, c2) {
lastColor = \'#FFFFFF\';
function tblColor(e) {
var e = window.event ? window.event : e;
var el1 = window.event ? window.event.srcElement : e.target;
var el = el1.parentNode;
if (el.tagName == \'TD\') {
el = el.parentNode;
}
var c = el.cells;
if (e.type == \'mouseover\') {
lasrColor = el.bgColor;
el.bgColor = c1;
for (var i = 0; i < c.length; i++) {
c[i].bgColor = c1;
}
} else {
if (c2 != \'\' && c2 != null) {
var setColor = c2;
} else {
var setColor = lasrColor;
}
el.bgColor = setColor;
for (var i = 0; i < c.length; i++) {
c[i].bgColor = setColor;
}
}
}
if (c1 == \'\') {
return false
}
var t = document.getElementById(id);
for (var i = 0; i < t.rows.length; i++) {
lastColor = t.rows[i].bgcolor;
list(t.rows[i], \'mouseover\', tblColor)
list(t.rows[i], \'mouseout\', tblColor)
}
}
function list(o, e, a) {
if (o.addEventListener) o.addEventListener(e, a, false);
else if (o.attachEvent) o.attachEvent("on" + e, a); else return null;
}