為什么這樣寫沒反應啊
? ? window.onload = function(){
? ? ? ? ? var tr=document.getElementsByTagName("tr");
? ? ? ? ? for(var i= 0;i<tr.length;i++)
? ? ? ? ? {
? ? ? ? ? ? ? tr[i].onmouseover=function(){
? ? ? ? ? ? ? ? ? tr[i].style.backgroundColor="#f2f2f2";
? ? ? ? ? ? ? }
? ? ? ? ? }
2015-04-29
樓上正解,內部函數有沒有定義的變量.
2015-04-29
tr[i].onmouseover=function(){
? ? ? ? ? ? ? ? ? this.style.backgroundColor="#f2f2f2";
? ? ? ? ? ? ? }
因為在function里 找不到tr[i]