zoukankan      html  css  js  c++  java
  • js实战之-倒计时

     1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     2 <html xmlns="http://www.w3.org/1999/xhtml">
     3 <head>
     4 <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
     5 <title>js-倒计时</title>
     6 </head>
     7 
     8 <body>
     9 
    10 <div id="box"></div>
    11 
    12 <script language="javascript">
    13 
    14 var timer2=new Date("5/01/2015 00:00:00");
    15 var tim_box=document.getElementById("box");
    16 var yer,days,hors,miu,sec;
    17 function  js(){
    18 var timer=new Date();
    19  yer=Math.floor((timer2-timer)/(365*24*60*60*1000));
    20  days=Math.floor((timer2-timer)/(24*60*60*1000)-(yer*365));
    21  hors=Math.floor((timer2-timer)/(1000*60*60)-(days*24)-(yer*365*24));
    22  miu=Math.floor((timer2-timer)/(60*1000)-(days*24*60)-(yer*365*24*60)-(hors*60));
    23  sec=Math.floor((timer2-timer)/1000-(days*24*60*60)-(yer*365*24*60*60)-(hors*60*60)-(miu*60));
    24 tim_box.innerHTML="距离2015年5月1日还有"+yer+""+days+""+hors+"小时"+miu+"分钟"+sec+"";
    25 setTimeout("js()",1000);
    26 }
    27 js();
    28 </script>
    29 
    30 </body>
    31 </html>
    一个不敬业的前端攻城狮
  • 相关阅读:
    java web使用WebSocket
    solr的使用
    mybatis中模糊查询的实现方式
    Java反射的简单使用
    TCP/IP协议 资料整理
    Java单向链表的实现
    Spring boot使用JWT来做接口登录验证
    sql性能优化
    前端实践项目(四)使用koa搭建开发环境
    前端实践项目 目录
  • 原文地址:https://www.cnblogs.com/chaoming/p/3183617.html
Copyright © 2011-2022 走看看