请问这段代码哪里出错了?为什么图片没法切换呢
window.onload=function(){
var wrap=document.getElementById('wrap'),
pic=document.getElementById('pic'),
list=document.getElementById('list').getElementsByTagName('li'),
index=0,
timer=null;
timer=setInterval(function(){
index++;
if(index>=list.length){
index=0;
}
for(var i=0;i<list.length;i++){
list[i].className="";
pic[i].style.display = "none";
}
list[index].className="on";
pic[index].style.display = "block";
},2000);
}