-
js实现倒计时
- <html>
- <head>
- <title>倒计时</title>
-
- <style type= "text/css">
- .daojishi h2
- {
- font-family:Helvetica, Microsoft YaHei, Arial, sans-serif;
- font-size:14px;
- margin-bottom:5px;
- color:#151515;
- }
- .daojishi #timer
- {
- font-family:Helvetica, Microsoft YaHei, Arial, sans-serif;
- font-size:14px;
- color:#151515;
- font-weight:bold;
- }
- </style>
- <script type = "text/javascript" src = "timer.js">
- </script>
- </head>
- <body onload = "timer()">
- <div class = "daojishi">
- <h2>剩余时间为:</h2>
- <div id = "timer">
- </div>
- </div>
- </body>
- </html>
- function timer()
- {
- var ts = (new Date(2018, 11, 11, 9, 0, 0)) - (new Date());
- var dd = parseInt(ts / 1000 / 60 / 60 / 24, 10);
- var hh = parseInt(ts / 1000 / 60 / 60 % 24, 10);
- var mm = parseInt(ts / 1000 / 60 % 60, 10);
- var ss = parseInt(ts / 1000 % 60, 10);
- dd = checkTime(dd);
- hh = checkTime(hh);
- mm = checkTime(mm);
- ss = checkTime(ss);
- document.getElementById("timer").innerHTML = dd + "天" + hh + "时" + mm + "分" + ss + "秒";
- setInterval("timer()",1000);
- }
- function checkTime(i)
- {
- if (i < 10) {
- i = "0" + i;
- }
- return i;
- }
-
相关阅读:
[最短路,floyd] Codeforces 1202B You Are Given a Decimal String...
ICPC 2015 Changchun A Too Rich(贪心)
2016 杭州区域赛补题
牛客网暑期ACM多校训练营(第六场) A Singing Contest
牛客网暑期ACM多校训练营(第六场)J Heritage of skywalkert
牛客网暑期ACM多校训练营(第六场)I Team Rocket (线段树)
It’s Time for a Montage
Attack on Alpha-Zet
ecna 2017 J Workout for a Dumbbell (模拟)
牛客网暑期ACM多校训练营(第二场)K carpet
-
原文地址:https://www.cnblogs.com/xurui01/p/3991108.html
Copyright © 2020-2023
润新知