[Js]javascript Countdown

Source: Internet
Author: User

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

Related Article

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.