选项索引位置问题
window.onload=function(){
var tab = document.getElementById("tabs");
var lilists = tab.getElementsByTagName("li");
var divlists = tab.getElementsByTagName("div");
for(var i=0,n=lilists.length;i<n;i++){
lilists[i].index = i;
lilists[i].onmouseover=function(){
for(var y=0;y<n;y++){
lilists[y].className="";
divlists[y].className="hidd";
}
this.className = "on";
divlists[this.index].className = "show";
}
};
}
为什么代码中
this.className = "on";
divlists[this.index].className = "show";
更改为
lilists[i].className ="on";
divlists[i].className = "show";
无法定位到相应元素,不能实现功能?