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

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

  • 相关阅读:
    Fiddler 简介
    jQuery 属性操作
    Win7的虚拟Wi-Fi
    接口与内部类
    继承(二)
    J2EE框架(Struts&Hibernate&Spring)的理解
    继承(一)
    对象与类
    控制流程
    数据类型
  • 原文地址:https://www.cnblogs.com/sunkaixuan1998/p/10286497.html
Copyright © 2011-2022 走看看