例子,js实现图片轮换,js图片轮播代码。 图片轮换-js图片轮播-bbs.it-home.org <li> var curIndex = 0; <li> var timeInterval = 1000; <li> var arr = new Array(); <li> arr[0] = "1 (1).jpg"; <li> arr[1] = "1 (2).jpg"; <li> arr[2] = "1 (3).jpg"; <li> arr[3] = "1 (4).jpg"; <li> arr[4] = "1 (5).jpg"; <li> arr[5] = "1 (6).jpg"; <li> arr[6] = "1 (7).jpg"; <li> arr[7] = "1 (8).jpg";<li> setInterval(changeImg,timeInterval); <li> function changeImg() { <li> var obj = document.getElementById("obj"); <li> if (curIndex == arr.length-1) { <li> curIndex = 0; <li> } else { <li> curIndex += 1; <li> } <li> obj.src = arr[curIndex]; <li> } <li> <li> setInterval(test,1000); <li> var array = new Array(); <li> var index = 0; <li> 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"); <li> function test() { <li> var myimg=document.getElementById("imgs"); <li> if(index==array.length-1) <li> { index=0; }else{ index++; } <li> myimg.src=array[index]; <li> } <li> 复制代码