为何这里window.onload的【闭合标签】要放在修改颜色的事件后,而不是最后的删除事件?
window.onload = function(){
// 鼠标移动改变背景,可以通过给每行绑定鼠标移上事件和鼠标移除事件来改变所在行背景色。
var tr= document.getElementsByTagName('tr');
for(var i=1;i<tr.length;i++){
tr[i].onmouseover=function addcolor(){
this.style.backgroundColor="#f2f2f2";
}
tr[i].onmouseout=function removecolor(){
this.style.backgroundColor="#ccc";
}
}
}