自动倒计时js实现

<div>距离下次自动刷新时间:<span id="times" style="font-size:14px;font-weight:600;color:red;">60</span>s;</div>

<script type="text/javascript">
$(function(){
var obj = $('#times');
setInterval(function(){
var time = parseInt(obj.html());
time--;
var s = time + '';
if(time < 10) {
s = '0' + s;
}
obj.html(s);
if(time == 0) {
window.location.reload();
}
}, 1000);
});
</script>

猜你喜欢

转载自blog.csdn.net/wang1253/article/details/79868967