<span id="minutes"></span>:<span id="seconds"></span>:<span id="ms"></span>
<script>
var maxtime = 2 * 60 *1000;
window.setInterval(()=>{
if (maxtime >= 0) {
var minutes = Math.floor(maxtime / 60/1000);
var seconds = Math.floor(maxtime/1000 % 60);
var ms = Math.floor(maxtime % 1000 / 10);
document.getElementById('minutes').innerHTML = minutes;
document.getElementById('seconds').innerHTML = seconds;
document.getElementById('ms').innerHTML = ms;
// var msg = "距离结束还有" + minutes + "分" + seconds + "秒" + ms + '毫秒';
maxtime-=10;
// console.log(msg)
}else{
console.log('倒计时结束')
}
},10)
</script>
网友评论