列表下划过的代码中,为什么只能用this不能用Lis[i]?
for (var i = 0; i < Lis.length; i++) {
Lis[i].onmouseover = function(){
this.style.background = '#567';
}
Lis[i].onmouseout = function(){
this.style.background = '#fff';
}
Lis[i].onclick = function(e){
var id = this.id;
e= e || window.event;
if(e.stopPropagation){
e.stopPropagation();
}else{
e.cancelBubble=true;
}
stateList.style.display = 'none';
stateTxt.innerHTML=getByClass('stateSelect_text',id)[0].innerHTML;
loginStateShow.className = "login-state-show "+id;
}
}上面那段
Lis[i].onmouseover = function(){
this.style.background = '#567';
}
我想改成Li[i].style.background = '#567'为什么就不能实现经过选项更换颜色?而非要使用this呢?this不是指向Lis[i]吗?