<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
//1、窗体加载后,单击播放,启动定时器播放图片
var arrs=["2.png","3.jpg","4.jpg"];
var i=0;
var obj;
$("[value='开始播放']").click(function(){
$(this).attr("disabled","disabled");
$(this).next().attr("disabled",false);
obj=window.setInterval(function(){
$("img").attr("src",arrs[i]);
i++;
if(i==arrs.length-1){
i=0;
}
},1000)
})
//2、窗体加载后,单击暂停,停止播放图片
$("[value='暂停播放']").click(function(){
$(this).attr("disabled","disabled");
$(this).prev().attr("disabled",false);
window.clearInterval(obj);
})
})
</script>
</head>
<body>
< img src="../../img/1.jpg" />
<input type="button" value="开始播放" />
<input type="button" value="暂停播放" />
</body>
</html>
标签:function,播放,attr,img,--,jpg,disabled,页面,轮播
From: https://blog.csdn.net/m0_68332771/article/details/144159783