//?鼠標移動改變背景,可以通過給每行綁定鼠標移上事件和鼠標移除事件來改變所在行背景色。
????????var?tr?=?document.getElementById("table").getElementsByTagName('tr');
???????
for(var?i=0;?i<tr.length;?i++)
????????{?
????????????tr[i].onmouseover?=?function(){
????????????//???tr[i].style.backgroundColor?=?"red";
??????????????this.style.backgroundColor?=?"red";??
????????????}
????????????tr[i].onmouseout?=?function(){
???????????????tr[i].style.backgroundColor="white";
????????????//???this.style.backgroundColor="white";
????????????}
????????}
?
?}
2016-07-16
tr[i].onmouseover?=?function(){
????????????//???tr[i].style.backgroundColor?=?"red";
??????????????this.style.backgroundColor?=?"red";??
????????????}
這里面是一個函數(shù)的調(diào)用, 在函數(shù)里面tr[i]是沒有被定義的,this是可以獲取標簽內(nèi)的對象的
懂了沒
2016-06-30
放在網(wǎng)頁中編譯一下可以發(fā)現(xiàn),tr[i]沒有被定義或者未被賦值。而this指的是table的tr子元素。所以二者不是同一個對象。
2016-06-27
七八 和十一、十二行的代碼