Javascript Countdown Source code. (min. seconds) Detailed annotation version _ time date

Source: Internet
Author: User
Tags setinterval
Write casually! Idle, bored! If the code has bugs, you are welcome to make a strong shot of bricks!
JS CODE
Copy Code code as follows:

<script type= "Text/javascript" language= "JavaScript" >
Total time, divided into units
var time = 100;
Hours
var h = parseint (TIME/60) > 0? parseint (TIME/60): 0;
Part
var m = time% 60;
Seconds
var s = 60;
Output to the DOM position of the current script
document.write (' <span> remaining <font id= "f_hh" > ' + H + ' </font> hour <font id= "f_mm" > ' + M + ' </font> Split <font id= "F_SS" > ' + S + ' </font> sec </span> ');
Start the countdown
var timeinterval = setinterval (function () {
If the time, minutes, and seconds are 0 o'clock, the current countdown will be stopped
if (h = = 0 && m = = 0 && s = = 0) {clearinterval (timeinterval);
When the seconds go to 0 o'clock, again for 60 seconds
if (s = = 0) {s = 60;}
if (s = = 60) {
Every time when the seconds go to 60 seconds, minutes minus one
M-= 1;
When the score equals 0 o'clock and the hour is 1 hours away, go inside and check it out.
if (m = = 0 && h > 0) {
Hour minus One
H-= 1;
Minutes automatically defaults to 60 points
m = 60;
seconds automatically defaults to 60 seconds
s = 60;
}
}
Seconds continue to beat, minus a
S-= 1;
Hour assignment
document.getElementById (' f_hh '). InnerHTML = h;
Minute assignment
document.getElementById (' f_mm '). InnerHTML = m;
Seconds Assignment
document.getElementById (' F_ss '). InnerHTML = S;
}, 1000);
</script>

HTML CODE
Copy Code code as follows:

<title>date demo</title>
<body>
<script type= "Text/javascript" language= "JavaScript" >
Total time, divided into units
var time = 100;
Hours
var h = parseint (TIME/60) > 0? parseint (TIME/60): 0;
Part
var m = time% 60;
Seconds
var s = 60;
Output to the DOM position of the current script
document.write (' <span> remaining <font id= "f_hh" > ' + H + ' </font> hour <font id= "f_mm" > ' + M + ' </font> Split <font id= "F_SS" > ' + S + ' </font> sec </span> ');
Start the countdown
var timeinterval = setinterval (function () {
If the time, minutes, and seconds are 0 o'clock, the current countdown will be stopped
if (h = = 0 && m = = 0 && s = = 0) {clearinterval (timeinterval);
When the seconds go to 0 o'clock, again for 60 seconds
if (s = = 0) {s = 60;}
if (s = = 60) {
Every time when the seconds go to 60 seconds, minutes minus one
M-= 1;
When the score equals 0 o'clock and the hour is 1 hours away, go inside and check it out.
if (m = = 0 && h > 0) {
Hour minus One
H-= 1;
Minutes automatically defaults to 60 points
m = 60;
seconds automatically defaults to 60 seconds
s = 60;
}
}
Seconds continue to beat, minus a
S-= 1;
Hour assignment
document.getElementById (' f_hh '). InnerHTML = h;
Minute assignment
document.getElementById (' f_mm '). InnerHTML = m;
Seconds Assignment
document.getElementById (' F_ss '). InnerHTML = S;
}, 1000);
</script>
</body>

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.