var tab = document.getElementById('tab');
var old_color = '';
for (var i = 0; i < tab.tBodies[0].rows.length; i++) {
if (i%2) {
tab.tBodies[0].rows[i].style.background = '#ccc';
} else {
tab.tBodies[0].rows[i].style.background = '';
}
tab.tBodies[0].rows[i].onmouseover = function () {
old_color = this.style.background;//改变颜色之前,先做一个保存记录
this.style.background = '#abcdef';
}
tab.tBodies[0].rows[i].onmouseout = function () {
this.style.background = old_color;
}
}