tr.setAttribute("onmouseover",dis1(tr));
tr.setAttribute("onmouseout",dis2(tr));
在添加按钮时,在新建的元素节点tr中添加这两个属性,咋没有啥效果的
tr.setAttribute("onmouseover","dis1()");
tr.setAttribute("onmouseout","dis2()"); function dis1(){
debugger;
console.log(event.target);
this.style.backgroundColor="#f2f2f2";
}
function dis2(){
debugger;
this.style.backgroundColor="#fff";
}
自己试下,看看this是什么,看看console.log(event.target)打印出什么。
我也觉得,要不加“”试下
然后,方法要不要也要用“”括起来,试试吧
方法里面是不是应该写的是this?