Add the container that displays the countdown on the Static Page, and reference the following script to use the time parameter.
TimeoutDate -- expiration time, in the format of 2014/01/01 or 2014/1/1
D -- day
H-hour
M -- minute
S -- seconds
Xs -- number 0 ~ 9
:
Code display:
Html:
Copy codeThe Code is as follows:
<Span id = "top_tuan_countdown"> </span>
Jquery:
Copy codeThe Code is as follows:
$ (). Ready (function (){
CcountDown ([, timeoutDate], ['and <B> <font color = "# ff0000" size = "4"> D </font> days </B> <font color = "# ff0000 "size =" 4 "> H </font> hour </B> <font color =" # ff0000 "size =" 4 "> M </font> </B> <font color = "# ff0000" size = "4"> S </font> seconds </B> <font color = "# ff0000 "size =" 4 "> xs </font> </B> expiration ', '',''], '# top_tuan_countdown', function () {$ ('# top_tuan_countdown '). remove ()});
})
Function CcountDown (t, c, _ self, fn ){
Function nd (d ){
Return isNaN (d )? (D? New Date (d). getTime (): new Date (). getTime (): d * 1000;
}
Var e = [nd (t [0]), nd (t [1]), nd (t [2])], _ s = _ self, B;
If (t [0] & e [0]> e [1]) {
((_S).html (c [1]);
Return;
} Else if (e [1]> e [2]) {
Fn & fn ($ (_ s ));
((_S).html (c [2]);
Return;
}
(B = function (l ){
Var l = l | (e [2]-e [1])/100, k = {
D: l/36000/24, H: l/36000% 24, M: l/600% 60, S: l/10% 60, xs: l % 10
};
((_S).html (c [0]. replace (/D | H | M | S | xs/g, function (m ){
Var n = parseInt (k [m]) +''
If (n. length = 1 & m! = 'D' & m! = 'Xs '){
N = 0 + n;
}
Return n
}));
SetTimeout (function (){
B (l-1)
},100 );
})()
}