關(guān)于事件綁定的,為什么注釋處的代碼能執(zhí)行,沒有注釋的不能?
var bindColor = function(){
for(var i = 0; i < as.length; i++)
{
var tr = as[i].parentNode.parentNode;
// tr.onmouseover = function(){
// this.style.backgroundColor ="#f2f2f2";
// }
// tr.onmouseout = function(){
// this.style.backgroundColor ="#fff";
// } ?
addEvent(tr,"onmouseover",function(){
this.style.backgroundColor ="#f2f2f2";
})
addEvent(tr,"onmouseout",function(){
this.style.backgroundColor ="#fff";
})
}
}
2015-09-17
問題已解決!