复制代码 代码如下: Bilder <br> var curIndex = 0; <br> var timeInterval = 1000; <br> var arr = new Array(); <br> arr[0] = "1 (1).jpg"; <br> arr[1] = "1 (2).jpg"; <br> arr[2] = "1 (3).jpg"; <br> arr[3] = "1 (4).jpg"; <br> arr[4] = "1 (5).jpg"; <br> arr[5] = "1 (6).jpg"; <br> arr[6] = "1 (7).jpg"; <br> arr[7] = "1 (8).jpg";<br> setInterval(changeImg,timeInterval); <br> function changeImg() { <br> var obj = document.getElementById("obj"); <br> if (curIndex == arr.length-1) { <br> curIndex = 0; <br> } else { <br> curIndex = 1; <br> } <br> obj.src = arr[curIndex]; <br> } <br> <br> setInterval(test,1000); <br> var array = new Array(); <br> var index = 0; <br> var array = new Array("1 (1).jpg","1 (2).jpg","1 (3).jpg","1 (4).jpg","1 (5) .jpg“, „1 (6).jpg“, „1 (7).jpg“, „1 (8).jpg“); <br> function test() { <br> var myimg=document.getElementById("imgs"); <br> if(index==array.length-1) <br> { index=0; }else{ index ; } <br> myimg.src=array[index]; <br> } <br>