问题描述
varimageArray=["aa.jpg","bb.jpg","cc.jpg"];varimageTimer;varimageIndex=1;varrotateFunc=function(){varimage=document.getElementById("img1");image.src="adv/"+imageArray[imageIndex];if(imageIndex==imageArray.length-1)imageIndex=0;elseimageIndex++;};//启动图片轮换functionstartRotate(){imageTimer=window.setInterval(rotateFunc,1000);}window.addEventListener("load",startRotate,false);//停止图片轮换functionstopRotate(){window.clearInterval(imageTimer);}
解决方案
时间: 2024-11-17 14:43:59