图片轮换效果实现代码(点击按钮停止执行)

时间:2013-04-12    点击:66   
在这个小程序中,需要把images文件夹下图片的命名设置为有顺序的,1、2、3……
复制代码 代码如下:

<script type="text/javascript">
var imgnumb = 1;
function imgfor() {
imgnumb++;
document.getElementById('img1').setAttribute('src', 'images/' + imgnumb + '.jpg');
if (imgnumb == 5) { //共5张图片
imgnumb = 0;
}
}
var clearid;
function clearfun() {
clearInterval(clearid);
}
clearid=setInterval(imgfor, 500);
</script>
</head>
<body>
<img alt="" id="img1" class="style1" src="images/1.jpg" width="500px" height="500px" />
<input type="button" value="结束执行" onclick="clearfun();" />
</body>
var imgnumb = 1;
function imgfor() {
imgnumb++;
document.getElementById('img1').setAttribute('src', 'images/' + imgnumb + '.jpg');
if (imgnumb == 5) {
imgnumb = 0;
}
}
var clearid;
function clearfun() {
clearInterval(clearid);
}
clearid=setInterval(imgfor, 500);
</script>
</head>
<body>
<img alt="" id="img1" class="style1" src="images/1.jpg" width="500px" height="500px" />
<input type="button" value="结束执行" onclick="clearfun();" />
</body>
利用webqq协议使用python登录qq发消息源码参考
setInterval,setTimeout与jquery混用的问题
JQueryEasyUI Layout布局框架的使用
JS 实现Json查询的方法实例
location对象的属性和方法应用(解析URL)
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved