用setAttribute設(shè)置onmouseover時(shí),屬性設(shè)為函數(shù)怎么不對了?
? ?var trs=document.getElementsByTagName("tr");
for(var i=0;i<trs.length;i++){
? ? ? ?trs[i].setAttribute("onmouseover" ,"color(this)");
? ? ? ? trs[i].setAttribute("onmouseout" , "javascript:this.style.backgroundColor = 'blue'");
}?
function color(obj){
obj.style.backgroundColor = 'red';
}
2016-02-19
第二個(gè)引號內(nèi)要么調(diào)用函數(shù),要么直接寫function(){}這樣的函數(shù)體