為什么這樣寫背景沒有變化
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"
? ? ? ? ? ?};
? ? ? ?}
? ? ? }
2016-10-05
因為你多了分號,for不能辨別你寫完循環(huán)沒有,所以把function(){};的分號去掉,把分號放到function(){code block ; }