Today to write things need to use the countdown, but also very interesting, posted out, hoping to help other people, writing is not very good, I hope that more valuable advice.
HTML code
<Divclass= "Price_time"> <Div> <spanclass= "Font1">Starting group Price:</span> <spanclass= "Font2"><spanclass= "Font4">¥</span>{$goods. Team_price}</span> <spanclass= "Font3">{$goods. Market_price}</span> </Div> <Div> <spanclass= "Font_time">00</span> <spanclass= "Font_time1">:</span> <spanclass= "Font_time">00</span> <spanclass= "Font_time1">:</span> <spanclass= "Font_time">00</span> <spanclass= "Font_time1">:</span> <spanclass= "Font_time">04</span> </Div></Div>
JS Code
/** * Created by Yu on 16/1/5.*/varI ={slideindex:1, Slidelength:0, Slidet:0, Stime:2000, Lastt:0, Ltime:0, Lday: {}, Lhour: {}, Lminutes: {}, Lseconds: {}, Numfat:function(num) {num=num.tostring (); if(Num.length = = 1) { return"0" +num; } Else { returnnum; }}, Lasttimeinit:function () { //Get Countdown content vari = 0; $(". Price_time Div. font_time"). each (function(Index, item) {Console.log (index+ ":" +$ (item). text ()); Switch(i) { Case0: I.lday.obj=$ (item); I.lday.value=$ (item). text (); Break; Case1: I.lhour.obj=$ (item); I.lhour.value=$ (item). text (); Break; Case2: I.lminutes.obj=$ (item); I.lminutes.value=$ (item). text (); Break; Case3: I.lseconds.obj=$ (item); I.lseconds.value=$ (item). text (); Break; } I++; }); //start the countdown .I.LASTT = SetInterval (function () { //i.ltime++;Console.log (I.lseconds.value); //seconds if(0 = =i.lseconds.value) {I.lseconds.value= 59; //points if(0 = =i.lminutes.value) {I.lminutes.value= 59; //when if(0 = =i.lhour.value) {I.lhour.value= 59; //days if(0 = =i.lday.value) {//Qing 0I.lseconds.value = 0; I.lminutes.value= 0; I.lhour.value= 0; //Stop Timercleartimeout (I.LASTT); //Hide Purchase button$ (". Buy_button"). Hide (); } Else{I.lday.value--; } } Else{I.lhour.value--; } } Else{I.lminutes.value--; } } Else{I.lseconds.value--; } //secondsI.lseconds.obj.text (I.numfat (I.lseconds.value)); //pointsI.lminutes.obj.text (I.numfat (I.lminutes.value)); //whenI.lhour.obj.text (I.numfat (I.lhour.value)); //daysI.lday.obj.text (I.numfat (I.lday.value)); }, 1000); }, Init:function () { //Countdown EventsI.lasttimeinit (); }}$(function() {i.init ();});
[Js]javascript Countdown