level 1
贴吧用户_0VZ5Z5e
楼主
非要这样!(如图)如何把这六个相同的JS代码,用一个浏览器打开就可以实现小时分钟秒的变化?

代码如下:
<script language =javascript >
var curIndex=0;
var timeInterval=1000;
var arr=new Array();
arr[0]="E:\Photos/0.png";
arr[1]="E:\Photos/1.png";
arr[2]="E:\Photos/2.png";
arr[3]="E:\Photos/3.png";
arr[4]="E:\Photos/4.png";
arr[5]="E:\Photos/5.png";
arr[6]="E:\Photos/6.png";
arr[7]="E:\Photos/7.png";
arr[8]="E:\Photos/8.png";
arr[9]="E:\Photos/9.png";
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>
<img id=obj src ="E:\Photos/0.png" width=52 height=85 border =0>
2018年05月29日 07点05分
1

代码如下:<script language =javascript >
var curIndex=0;
var timeInterval=1000;
var arr=new Array();
arr[0]="E:\Photos/0.png";
arr[1]="E:\Photos/1.png";
arr[2]="E:\Photos/2.png";
arr[3]="E:\Photos/3.png";
arr[4]="E:\Photos/4.png";
arr[5]="E:\Photos/5.png";
arr[6]="E:\Photos/6.png";
arr[7]="E:\Photos/7.png";
arr[8]="E:\Photos/8.png";
arr[9]="E:\Photos/9.png";
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>
<img id=obj src ="E:\Photos/0.png" width=52 height=85 border =0>