用jQuery按照步驟寫卻木有任何反應(yīng),求解……
?window.onload=function(){ ????var?wrap=document.getElementById('wrap'), ????????pic=document.getElementById('pic').getElementsByTagName('li'), ????????list=document.getElementById('list').getElementsByTagName('li'), ????????index=0, ????????timer=null; ??????//?定義并調(diào)用自動播放函數(shù) timer?=?setInterval(autoPlay,1500); ??????//?定義圖片切換函數(shù) ????? function?changePic(curIndex){ for(var?i=0;i<pic.length;i++){ pic[i].style.display="none"; list[i].className=""; } pic[curIndex].style.display="block"; list[curIndex].className="on"; } ?//設(shè)置自動播放函數(shù)(1~5循環(huán)) ?function?autoPlay(){ ?if(++index>=pic.length){index=0}; ?changePic(index);} ? ?????//?鼠標(biāo)劃過整個容器時停止自動播放 wrap.onmouseover?=?function(){clearInterval(timer);} ?????//?鼠標(biāo)離開整個容器時繼續(xù)播放至下一張 ???? wrap.onmouseout?=?function(){timer?=?setInterval(autoPlay,1500);} ?????//?遍歷所有數(shù)字導(dǎo)航實現(xiàn)劃過切換至對應(yīng)的圖片 for(var?i=0;i<=pic.length;i++){ list[i].onmouseover?=?function(){ clearInterval(timer); index=this.innerText-1; changePic(index); }; }; ???};
這個是JS寫的,可以用,但是我用jquery寫就沒反應(yīng)了,求解
2015-06-03
小改了四處 : )
2015-07-31
今天一看發(fā)現(xiàn)不行了,我剛改了那會兒可以嗎?
2015-05-12
changePic( )這個函數(shù),不要用遍歷,你既然用了數(shù)組,那就用for循環(huán)好了
2015-05-12
把$("list")這些括號里的引號去掉。變量不要加引號~~