Jquery countdown source code sharing

Source: Internet
Author: User

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 );
})()
}

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.