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