1.这个是倒计时的代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input type="text">
<button id="start">开始倒计时</button>
<script>
var start= document.getElementById("start");
var num = 15;
var timer ;
start.οnclick=function(){
timer = setInterval(function(){
num--;
if(num==0){
clearInterval(timer);
}
console.log(num);
document.querySelector("input").value=num;
},1000);
}
</script>
</body>
VS.倒计时
最新推荐文章于 2024-08-27 15:59:21 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)