标签:
<div class="banner">
<img src="img/banner1.jpg" id="obj">
</div>
<script language =javascript >
var curIndex=0;
var timeInterval=2000;
var arr=new Array();
arr[0]="img/banner1.jpg";
arr[1]="img/banner2.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];
}
</script>
标签:
原文地址:http://www.cnblogs.com/hyql/p/5063683.html