1 <script language =javascript > 2 var curIndex=0; 3 //时间间隔 单位毫秒 4 var timeInterval=1000; 5 var arr=new Array(); 6 arr[0]="1.jpg"; 7 arr[1]="2.jpg"; 8 arr[2]="3.jpg"; 9 arr[3]="4.jpg"; 10 arr[4]="5.jpg"; 11 arr[5]="6.jpg"; 12 arr[6]="7.jpg"; 13 setInterval(changeImg,timeInterval); 14 function changeImg() 15 { 16 var obj=document.getElementById("obj"); 17 if (curIndex==arr.length-1) 18 { 19 curIndex=0; 20 } 21 else 22 { 23 curIndex+=1; 24 } 25 obj.src=arr[curIndex]; 26 } 27 </script> 28 <img id=obj src ="1.jpg" border =0 />
时间: 2024-10-11 01:07:21