JS Implementation Countdown

Source: Internet
Author: User

  1. <html>
  2. <head>
  3. <title> Countdown </title>
  4. <!--The following CSS styles--
  5. <style type= "Text/css">
  6. . Daojishi H2
  7. {
  8. Font-family:helvetica, Microsoft Yahei, Arial, Sans-serif;
  9. font-size:14px;
  10. margin-bottom:5px;
  11. Color: #151515;
  12. }
  13. . Daojishi #timer
  14. {
  15. Font-family:helvetica, Microsoft Yahei, Arial, Sans-serif;
  16. font-size:14px;
  17. Color: #151515;
  18. Font-weight:bold;
  19. }
  20. </style>
  21. <script type = "Text/javascript" src = "timer.js">
  22. </Script>
  23. </head>
  24. <body onload = "timer ()">
  25. <div class = "Daojishi">
  26. <h2> remaining time:</h2>
  27. <div id = "timer">
  28. </div>
  29. </div>
  30. </Body>
  31. </html>

  1. function timer ()
  2. {
  3. var ts = (new Date (2018, one, one, 9, 0, 0))-(new Date ()); Calculates the number of milliseconds remaining for the month minus one months
  4. var dd = parseint (TS/1000/60/60/24, 10); //Calculate the remaining days
  5. var hh = parseint (ts/1000/60/60% 24, 10); //Calculate the number of hours remaining
  6. var mm = parseint (ts/1000/60% 60, 10); //Calculate the number of minutes remaining
  7. var ss = parseint (ts/1000% 60, 10); //Calculate the number of seconds remaining
  8. DD = Checktime (DD);
  9. HH = Checktime (hh);
  10. MM = Checktime (mm);
  11. SS = Checktime (ss);
  12. document.getElementById ("Timer"). InnerHTML = dd + "Day" + hh + "when" + mm + "min" + ss + "SEC";
  13. SetInterval ("timer ()", 1000);
  14. }
  15. function Checktime (i)
  16. {
  17. if (i <) {
  18. i = "0" + i;
  19. }
  20. return i;
  21. }

JS Implementation Countdown

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.