无意中在网上发现的,代码非常的简单,一看就明白! 复制代码 代码如下: <BR>var curIndex=0; <BR>//时间间隔 单位毫秒 <BR>var timeInterval=5000; <BR>var arr=new Array(); <BR>arr[0]="1.jpg"; <BR>arr[1]="2.jpg"; <BR>arr[2]="3.jpg"; <BR>arr[3]="4.jpg"; <BR>arr[4]="5.jpg"; <BR>arr[5]="6.jpg"; <BR>arr[6]="7.jpg"; <BR>setInterval(changeImg,timeInterval); <BR>function changeImg() <BR>{ <BR>var obj=document.getElementById("showpic"); <BR>if (curIndex==arr.length-1) <BR>{ <BR>curIndex=0; <BR>} <BR>else <BR>{ <BR>curIndex+=1; <BR>} <BR>obj.src="image/"+arr[curIndex]; <BR>} <BR> 好了以上就是全部的代码