function highlightRows() { if(!document.getElementsByTagName) return false; var tables = document.getElementsByTagName("table"); for(var i=0;i<tables.length;i++){ var rows = tables[i].getElementsByTagName("tr"); for(var j =0;j<rows.length;j++){ rows[j].onmouseover=function(){ //rows[j].style.fontWeight="bold"; //這樣無效 this.style.fontWeight="bold"; } rows[j].onmouseout=function() { //rows[j].style.fontWeight="normal"; //這樣無效 this.style.fontWeight="normal"; } } }}為什么注釋的那兩行不行,非要用this呢,這里this不是應該就是指代rows[j]么?
為什么此js函數里只能用this才能實現?
炎炎設計
2018-08-07 13:13:20
