window.onload = function() { var oUl1 = document.getElementById("ul1"); var aLi = oUl1.getElementsByTagName("li"); var oDiv = document.getElementById("tab-list"); var aDiv = oDiv.getElementsByTagName("div"); for(var i = 0; i < aLi.length; i++) { aLi[i].index=i; aLi[i].onmouseover = function() { for(var i = 0; i < aLi.length; i++) { aLi[i].className = ""; } this.className = "a1"; for(var j = 0; j < aDiv.length; j++) { aDiv[j].className = "hide"; } aDiv[this.index].className = ""; } } }他这个是先for循环3次,还是就循环一次直接触发事件?
添加回答
举报
0/150
提交
取消