<script type="text/javascript">
var aa=0;
//设置变换时间为2s
var timeChange=2000;
//定义数组
var arr = new Array();
arr[0]="image/01.jpg";
arr[1]="image/02.jpg";
arr[2]="image/03.jpg";
arr[3]="image/04.jpg";
//调用setInterval函数
setInterval(ChangeImg, timeChange);
function ChangeImg(){
var image = document.getElementById("image");
if(aa==arr.length-1){
aa=0;
}else{
aa+=1;
}
image.src=arr[aa];
}
</script>
</head>
<body>
<img src="image/01.jpg" id="image"></img>
</body>
时间: 2024-10-05 04:24:37