<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<input type="button" id="btn" value="倒计时开始"></input>
<script>
var wait=5;
function time(o) {
if (wait == 0) {
o.removeAttribute("disabled");
o.value="倒计时开始";
wait = 5;
}else{
o.setAttribute("disabled", true);
o.value=wait;
wait--;
setTimeout(function(){
time(o)
},1000);
}
}
document.getElementById("btn").onclick=function(){time(this);}
</script>
</body>
</html>
JS setTimeout倒计时
最新推荐文章于 2025-03-14 17:54:29 发布