1.设置一个时长的倒计时
思路
设置一个数字变量,单位是秒,变量取余得到剩余的分和秒,定时器中此变量每秒自减
代码
html
<div class="box">
<div class="clock"></div>
</div>
css
.box {
width: 600px;
height: 300px;
background: #000;
margin: 0 auto;
}
.clock {
width: 100%;
height: 100%;
text-align: center;
line-height: 300px;
font-size: 35px;
font-weight: 900;
}
js
var box = document.querySelector(".box");
var clock = document.querySelector(".clock");
var setT = 0 * 60 + 5; //设置一个时间长度
var minute, second;
var timer = '';
clearInterval(timer)