window.onload = function(){
var x=document.getElementsByTagName("tr");
for(i=0;i<x.length;i++){
x[i].onmouseover=function(){
x[i].style.backgroundColor="#f2f2f2"
};
x[i].onmouseout=function(){
x[i].style.backgroundColor="#fff"
};
}
}
因为你多了分号,for不能辨别你写完循环没有,所以把function(){};的分号去掉,把分号放到function(){code block ; }