最简单的js图片切换效果实现代码
![时间](/skin/images/news-belong-1.png)
![作者](/skin/images/news-belong-2.png)
![浏览](/skin/images/news-belong-3.png)
var curIndex=0;
//时间间隔 单位毫秒
var timeInterval=2000;
var arr=new Array();
arr[0]="images/1.jpg";
arr[1]="images/2.jpg";
arr[2]="images/3.jpg";
arr[3]="images/4.jpg";
setInterval(changeImg,timeInterval);
function changeImg()
{
var obj=document.getElementById("obj");
if (curIndex==arr.length-1)
{
curIndex=0;
}
else
{
curIndex+=1;
}
obj.src=arr[curIndex];
}