Simple and practical countdown Effect of JS

Source: Internet
Author: User

I did not study the countdown effect, so I practiced it myself.

 <!  Doctype html  >  <  Html  >  <  Head  >  <  Meta  Charset  = "UTF-8"  >  <  Title  > Countdown </  Title  >  <  Meta  Name  = "Author"  Content  = ""  >  <  Meta  Name  = "Keywords"  Content  = ""  > <  Meta  Name  = "Description"  Content  = ""  >  <  Style  Type  = "Text/CSS"  >  *  {  Margin :  0  ;  Padding  :  0  ;      }  Ul, Li  {  List-style  : None  ;  }  # Show_time  {  Color  :  # F00  ;  Font-size  :  24px ;  Font-weight  :  Bold  ;  }  </  Style  >  </  Head  >  <  Body  > <  Div  ID  = "Show_time"  >  </  Div  >  <  Script  Type  = "Text/JavaScript"  >   Function  Countdown (){ VaR  Show_time  =  Document. getelementbyid (  "  Show_time  "  ); Endtime  =   New  Date ( "  12/31/2012 23:59:59  "  );  //  End Time  Today  =   New  Date ();  //  Current Time Delta_t  =  Endtime. gettime ()  -  Today. gettime ();  //  Interval      If  (Delta_t  <   0 ) {Clearinterval (auto); show_time.innerhtml  =   "  Countdown has ended  "  ;} Window. setTimeout (countdown,  1000  ); Total_days  =  Delta_t  / (24*60*60*1000 );  //  Total days  Total_show  =  Math. Floor (total_days );  //  Actual Number of days displayed  Total_hours  =  (Total_days -  Total_show)  *  24  ;  //  Remaining hours  Hours_show  =  Math. Floor (total_hours );  // Actual displayed hours  Total_minutes  =  (Total_hours  -  Hours_show)  *  60  ;  //  Remaining minutes Minutes_show  =  Math. Floor (total_minutes );  //  Actually displayed minutes  Total_seconds  =  (Total_minutes  -  Minutes_show)  * 60  ;  //  Remaining minutes  Seconds_show  =  Math. Floor (total_seconds );  //  Number of seconds actually displayed  Show_time.innerhtml  =  "  There are also:  "   +  Total_show  +   "  Days  "   +  Hours_show  +  "  Hour  "   +  Minutes_show  +   "  Minute  "   +  Seconds_show  +  "  Seconds  "  ;} Countdown ();  </  Script  >  </  Body  >  </  Html  > 

 

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.