How to Implement the second kill in jquery countdown Effect

Source: Internet
Author: User

Copy codeThe Code is as follows:
<Script type = "text/javascript">
$ (Function (){
CountDown ("2015/9/8 11:11:59", "# colockbox1 ");
});
Function countDown (time, id ){
Var day_elem = $ (id). find ('. Day ');
Var hour_elem = $ (id). find ('. hour ');
Var minute_elem = $ (id). find ('. minute ');
Var second_elem = $ (id). find ('. second ');

// If (typeof end_time = "string ")
Var end_time = new Date (time). getTime (), // The month is the actual month-1
Sys_second = (end_time-new Date (). getTime ()/1000;
Var timer = setInterval (function (){
If (sys_second> 1 ){
Sys_second-= 1;
Var day = Math. floor (sys_second/3600)/24 );
Var hour = Math. floor (sys_second/3600) % 24 );
Var minute = Math. floor (sys_second/60) % 60 );
Var second = Math. floor (sys_second % 60 );
Day_elem & $ (day_elem). text (day); // computing day
$ (Hour_elem). text (hour <10? "0" + hour: hour); // computing hour
$ (Minute_elem). text (minute <10? "0" + minute: minute); // computing minutes
$ (Second_elem). text (second <10? "0" + second: second); // calculate the second kill
} Else {
ClearInterval (timer );
}
},1000 );
}
</Script>

Html:
Copy codeThe Code is as follows:
<Div class = "colockbox" id = "colockbox1">
<Span class = "day"> 00 </span>
<Span class = "hour"> 00 </span>
<Span class = "minute"> 00 </span>
<Span class = "second"> 00 </span>
</Div>

The company has made a second kill page and requires a countdown effect.

Code demo download: http://www.jb51.net/jiaoben/103648.html

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.