<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>倒计时10秒按钮</title>
</head>
<body>
<button "start()">开始</button>
<button "stop()">停止</button>
<strong id="time">10</strong>
</body>
<script type="text/javascript">
var times = null;
function start(){
time.innerHTML=10;
if (times!= null) {
return false
}
var num = 10;
times =setInterval(function(){
num--;
time.innerHTML=num;
if (num==0) {
stop();
}
},1000)
}
function stop(){
alert("倒计时停止");
clearInterval(times);
times = null;
}
</script>
</html>
十秒倒计时开始停止按钮
最新推荐文章于 2022-09-20 10:29:55 发布