.one{
background-color:#F0FFF0;
}
.two{
background-color:white;
}
.over{
background-color:#C1CDC1;
}
</style>
<script type="text/javascript">
function gehang() {
var trlist = document.getElementsByTagName("tr");
for ( var i = 1; i < trlist.length; i++) {
//进行遍历,并且判断
if (i % 2 == 0) {
trlist[i].className = "two";
} else {
trlist[i].className = "one";
}
var oldcolor;
//实现当鼠标移动到该行,该行背景加深、
trlist[i].onmouseover = function() {
oldcolor = this.className;
//重新设置新颜色
this.className = "over";
};
trlist[i].onmouseout = function() {
//当鼠标离开,自动还原颜色
this.className = oldcolor;
};
}
}
</script>
<body οnlοad="gehang()">