用setAttribute设置onmouseover时,属性设为函数怎么不对了?
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';
}