无为清净楼资源网 Design By www.qnjia.com

本文实例讲述了基于JS实现的倒计时程序。分享给大家供大家参考。具体实现方法如下:

剩余时间:<i id="expireTime"></i>
<script type="text/javascript">
  var expire = 2412169;
  var expireTime = function(expires){
    if(expires > 0){
      var second = expires;
    }else{
      var second = "0 分";
      return second;
    }
    var day = hour = min = "";
    if(second>86400){
      day = Math.floor(second/86400)+"天 ";
      second = second%86400;
    }
    if(second>3600){
      hour = Math.floor(second/3600)+"时 ";
      second = second%3600;
    }
    if(second>60){
      min = Math.floor(second/60)+"分 ";
      second = second%60;
    }
    second = second+"秒";
    return day+hour+min+second;
  }
  var timeEle = document.getElementById("expireTime");
  var timer = window.setInterval(function(){
    timeEle.innerHTML = expireTime(expire--);
    if(expire<0){
      clearInterval(timer);
    }
  },1000);
</script>

希望本文所述对大家的javascript程序设计有所帮助。

标签:
JS,倒计时

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com