• 倒计时


    <!DOCTYPE html>
    <html>
     <head>
      <meta charset="UTF-8">
      <title></title>
      <style type="text/css">
       div{ 400px; height: 200px; background-color: #00FFFF;}
       div span{font-size:20px; float: left; line-height: 200px; margin-left: 100px;}
      </style>
     </head>
     <body onload="leftTimer()">
      <div>
       <span id="timer"></span>
      </div>
      <script type="text/javascript">
       function leftTimer(year,month,day,hour,minute,second){
         var leftTime = (new Date(year,month-1,day,hour,minute,second)) - (new Date()); //计算剩余的毫秒数
         var days = parseInt(leftTime / 1000 / 60 / 60 / 24 , 10); //计算剩余的天数
         var hours = parseInt(leftTime / 1000 / 60 / 60 % 24 , 10); //计算剩余的小时
         var minutes = parseInt(leftTime / 1000 / 60 % 60, 10);//计算剩余的分钟
         var seconds = parseInt(leftTime / 1000 % 60, 10);//计算剩余的秒数
         days = checkTime(days);
         hours = checkTime(hours);
         minutes = checkTime(minutes);
         seconds = checkTime(seconds);
         setInterval("leftTimer(2019,1,19,8,1,1)",1000);
         document.getElementById("timer").innerHTML = days+"天" + hours+"小时" + minutes+"分"+seconds+"秒"; 
       }
       function checkTime(i){ //将0-9的数字前面加上0,例1变为01
         if(i<10)
         {
           i = "0" + i;
         }
         return i;
       }
      </script>
     </body>
    </html>

  • 相关阅读:
    LeetCode 50: Pow(x, n)
    Codility 1: equilibrium
    LeetCode 49: Anagrams
    crackme160--(5)
    crackme160--(4)
    魔兽显血改键工具的脱壳和修改
    crackme160--(3)
    crackme160--(1)
    python-装饰器
    编程语言C++01-C++入门学习路线
  • 原文地址:https://www.cnblogs.com/sunkaixuan1998/p/10286497.html
Copyright © 2020-2023  润新知