自动倒计时js实现

xiaoxiao2021-02-28  36

<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>

转载请注明原文地址: https://www.6miu.com/read-2628009.html

最新回复(0)