請看代碼快照 有問題咨詢 謝謝
? ? ? ? ? ? ?hh= document.getElementsByTagName("tr");?
? ? ? ? ? for(var i=1;i<hh.length;i++) {
? ? ? ? ? ? ? hh[i].onmouseover=function(){
? ? ? ? ? ? ? ? ?this.style.backgroundColor="#f2f2f2"; ? ? //為什么這里用this啊 ??
? ? ? ? ? ? ? }
? ? ? ? ? ? ?hh[i].onmouseout = function(){
? ? this.style.backgroundColor ="#fff"; ?//為什么這里用 this啊
? ? ? ? ? ? ? }
<td><a href="javascript:;"onclick="del(this)" >刪除</a></td> ? ? ?//還有調用的函數里面 為什么也是tihs
具體可以看代碼快照
2015-06-04
this表示當前的元素
第一個this表示你鼠標劃入的當前元素
第二個this表示你鼠標滑出的當前元素
第三個this表示你鼠標點擊的當前元素