用个嵌套循环不就可以了嘛?可能有点不规范:
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"; } }
2015-04-01
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就可以了。
举报