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不是應(yīng)該就是指代rows[j]么?
為什么此js函數(shù)里只能用this才能實(shí)現(xiàn)?
炎炎設(shè)計(jì)
2018-08-07 13:13:20