Use JavaScript for a simple countdown function

Source: Internet
Author: User

The effect is as follows:

1 <Divclass= "Warp">2     <PID= "txt">Distance to "11" National Day holiday also:</P><BR>3     <PID= "Time"></P>4 </Div>

JavaScript Source code:

1<script>2$ (document). Ready (function(e) {3         4         functiontimer ()5         {6             //Get system Current time7             varseconds;8             varminutes;9             varhours;Ten             varDays ; One             varYear ; A             varmouth; -              -             varDate =NewDate (); theseconds =date.getseconds (); -minutes =date.getminutes (); -Hours =date.gethours (); -Year =date.getfullyear (); +mouth = Date.getmonth () +1; -Days =date.getdate (); +              A             //because date gets the current time month is 0-11, less than one months, so you need to get to each time, redefine the current time at             varShiyi =NewDate (2015,10,1,0,0,0); -             varNowdate =NewDate (year,mouth,days,hours,minutes,seconds); -              -             varShiyitime =shiyi.gettime (); -             varNowtime =nowdate.gettime (); -              in             varCTime = Shiyitime-Nowtime; -             varCDD = Checktime (parseint (ctime/(1000*60*60*24), 10)); to             varCHH = Checktime (parseint (ctime/1000/60/60%24,10)); +             varCMM = Checktime (parseint (ctime/1000/60%60,10)); -             varCSS = Checktime (parseint (ctime/1000%60,10)); the              *             functionchecktime (i) $             {Panax Notoginseng                 if(I < 10) -                 { thei = "0" +i;  +                 }     A                 returni; the             } +              -document.getElementById ("Time"). InnerHTML = cdd+ "Days" +chh+ "+cmm+" minutes "+css+" seconds "; $         } $SetInterval (timer,1000); -             -     }); the</script>

Use JavaScript for a simple countdown function

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.