Provides various official and user-released code examples. For code reference, you are welcome to exchange and learn. This article takes the countdown of the Group Buying website as an example to give the end time and the end time of the Spring Festival in 2016 to the three commodities.
The demo and Free Download Links are available at the bottom of the page. If you want to see more
Js Special Effects,
Website source code,
Js tutorialPlease visit the http://www.sucaihuo.com/js and DEMO, most of all can be downloaded for free.
We define the end time stamp for the three items respectively, that is, the class is the value of the ". endtime" attribute.
Mayiner 2015 Korean new printing summer dress
New two-piece set of 2015 summer clothes on amoeba
New Korean version of yingcurtain 2015 Spring women's clothing
JQuery
The code in setInterval is executed every 100 milliseconds at a time for each item. Then, the each () method traverses and computes the countdown of each item, in the unit of days, hours, minutes, and seconds.
Var time_current = (new Date (). valueOf (); // get the current time
$ (Function (){
Var dateTime = new Date ();
Var difference = dateTime. getTime ()-time_current;
SetInterval (function (){
$ (". Endtime"). each (function (){
Var obj = $ (this );
Var endTime = new Date (parseInt (obj. attr ('value') * 1000 );
Var nowTime = new Date ();
Var nMS = endTime. getTime ()-nowTime. getTime () + difference;
Var myD = Math. floor (nMS/(1000*60*60*24 ));
Var myH = Math. floor (nMS/(1000*60*60) % 24;
Var myM = Math. floor (nMS/(1000*60) % 60;
Var myS = Math. floor (nMS/1000) % 60;
Var myMS = Math. floor (nMS/100) % 10;
If (myD> = 0 ){
Var str = myD + "day" + myH + "Hour" + myM + "Minute" + myS + "." + myMS + "second ";
} Else {
Var str = "ended! ";
}
Obj.html (str );
});
},
100 );
});See this special effect demo and free download, visit the http://www.sucaihuo.com/js/36.html
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB