在这个小程序中,需要把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="/UploadFiles/2021-04-02/1.jpg"><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="/UploadFiles/2021-04-02/1.jpg"><input type="button" value="结束执行" onclick="clearfun();" />
</body>
复制代码 代码如下:
<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="/UploadFiles/2021-04-02/1.jpg"><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="/UploadFiles/2021-04-02/1.jpg"><input type="button" value="结束执行" onclick="clearfun();" />
</body>
标签:
图片轮换,停止按钮
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com
暂无“图片轮换效果实现代码(点击按钮停止执行)”评论...