這段代碼是什么意思
function change(curIndex){ ? ?
pic.style.marginTop=-170*curIndex+'px'; ? ?
for(var n=0;n<list.length;n++){ ? ?
list[n].className=''; ? ?
} ? ?
list[curIndex].className='on'; ? ?
index=curIndex; ? ?
} ? ?
wrap.onmouseover=function(){ ? ?
clearInterval(timer); ? ?
} ? ?
wrap.onmouseout=auto; ? ?
for(var i=0;i<list.length;i++){ ? ?
list[i].id=i; ? ?
list[i].onmouseover=function(){ ? ?
change(this.id); ? ?
} ? ?
} ? ?
2017-05-12
wrap.onmouseout=auto; ? 這里是當(dāng)鼠標(biāo)移出容器時恢復(fù)自動播放,
wrap.onmouseout=function() {timer=setInterval(autoPlay,1000);}這是我的寫法,至于這里為什么用auto就不清楚了
2017-05-12
function change(curIndex){ ? ?????????????????????????????????????//這是切換位置的函數(shù)
????pic.style.marginTop=-170*curIndex+'px'; ? ??????????//這里的pic是整個圖片列表的ul,通過改變上邊距來讓不
????????????????????????????????????????????????????????????????????????????????? ?//同位置的圖片顯示在窗口中,從而達(dá)到切換圖片的效果
????for(var n=0;n<list.length;n++){ ? ??????????????????????????//這里是把所有數(shù)字導(dǎo)航樣式去掉
????????list[n].className=''; ? ?
????} ? ?
????list[curIndex].className='on'; ? ?????????????????????????? //是當(dāng)前的數(shù)字導(dǎo)航高亮
????index=curIndex; ? ?????????????????????????????????????????????????//更新索引
} ? ?
wrap.onmouseover=function(){ ? ?????????????????????????????//鼠標(biāo)滑過容器的時候去除自動播放
????clearInterval(timer); ? ?
} ? ?
wrap.onmouseout=auto; ? ?????????????????????????????????????? ?//這里就不清楚了,你的代碼沒復(fù)制全,從這些代碼中
????????????????????????????????????????????????????????????????????????????????? ?//只能分析出這些作用
for(var i=0;i<list.length;i++){ ? ??????????????????????????????????//這里是鼠標(biāo)滑過數(shù)字導(dǎo)航時移動到對應(yīng)圖片上
????list[i].id=i; ? ?
????list[i].onmouseover=function(){ ? ?
????????change(this.id); ? ?
????} ? ?
} ? ?