zoukankan      html  css  js  c++  java
  • 倒计时

    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <title>限时抢</title>
      <link rel="stylesheet" type="text/css" href="style.css">
      <script type="text/javascript">
        window.onload = function(){
          showTime();
        }
        function showTime(){
          var endTime = new Date("2017/7/15,9:30:00");
          var startTime = new Date();
          var leftSeconds = parseInt((endTime.getTime()-startTime.getTime())/1000);//两个时间点之间的秒数
          var d = parseInt(leftSeconds/(60*60*24));//天数,这个直接取整
          var h = parseInt(leftSeconds/3600)%24;//注意这里,小时需要求余24,为了获取天数之外的小时数
          var m = parseInt(leftSeconds/60)%60;//只获取残留的分钟数
          var s = leftSeconds%60;//残留的秒数
          if(leftSeconds<=0){
            document.getElementById("LeftTime").innerHTML="团购已结束";
          }else{
            document.getElementById("LeftTime").innerHTML=d+""+h+"小时"+m+""+s+"";
            setTimeout(showTime,500);
          }
        }
      </script>
    </head>
    <!--
    计算距离某个时间点的多少天多少小时多少分多少秒
    -->
    <body>
      <div class="content3">
      <div class="time">还剩 <span id="LeftTime"></span></div>
      </div>
    </body>
    </html>
     
    效果:
  • 相关阅读:
    maven
    sublime text
    ios category
    python
    activiti
    出版社
    gradle
    selenium
    spring
    Ansible状态管理
  • 原文地址:https://www.cnblogs.com/liuna/p/7168922.html
Copyright © 2011-2022 走看看