js 倒计时,在html中显示,距离刷新还有几秒
展开全部
倒计时代码案例:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>HTML5学堂(码匠)</title>
</head>
<body>
<div class="wrap">倒计时<span class="time"></span></div>
<script type="text/javascript">
var timeEle = document.querySelector('.time'),
count = 10;
timeEle.innerHTML = count;
// 设置计时器
var judge = setInterval(function() {
count--;
if (!count) {
// 清除计时器
clearInterval(judge);
};
// 标签当中显示时间
timeEle.innerHTML = count;
}, 1000);
</script>
</body>
</html>
倒计时效果:
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询