for(var i =0; i<aLi.length;i++){ aLi[i].onmouseover=function(){ for(var j=0;j<aLi.length;j++){ var This=aLi[j]; This.className=""; } var This=this; This.className="big"; } }
for(var i =0; i < aLi.length; i++){ aLi[i].onmouseover = function () { // for(var j = 0; j < aLi.length; j++){ // var This = aLi[j]; // This.className = ""; // } // var This = this; this.className = "big"; } aLi[i].onmouseout = function () { this.className = ""; } }
如果只是为了让鼠标所指的元素加上指定class,那么鼠标移出的时候移出class就可以了。