JS Countdown function Source code

Source: Internet
Author: User


<div class= "Time Timers" rel= "<?php echo date (' m/d/y ', Time () +24*3600)?>" > <span class= "Ico_time" ></span> <span class= "Data_title" > Remaining <span class= "Data_pink Pi Nkft "><span class=" hours ">7</span> <span class=" mins ">46</span> sub <span class=" "> 33</span> sec </span>
</span> </span> </div>


Here is the JS code

 $ (document). Ready (function () {timing ();}); /Countdown function timing () {    $ (". Timers"). each (function () {        var endtime = new Date ($ (thi s). attr ("rel")). GetTime ();        var nowtime = new Date ();         var Youti me = 0;               Youtime = endtime-nowtime;       &NBSP ; var seconds = youtime/1000;        var minutes = Math.floor (SECONDS/60);        VA R hours = Math.floor (MINUTES/60);        var chour= hours% 24;        var cminute = minutes% 60;        var csecond= math.floor (seconds%60);//"%" var ms=math.floor (youtime)% 10;        if (endtime<=nowtime) {           //$ (this). HTML ("expired")// If the end date is less than the current date, the prompt expires        }else{            $ (this). HTML ("Still <span class= ' pinkft data_pink ' ><span class= ' hours ' >" +chour+ "</span> <span class= ' mins ' > "+cminute+" </span> <span class= ' > ' +csecond+ '. ' +ms+ "</span> sec </span>");                  if (Chour <) {                $ ("#hours"). Text ("0" +chour);           }else{        &NBS P       $ ("#hours"). Text (chour);           }             if (Cminute < ten) {                $ ("#minute"). Text ("0" +cminute); nbsp          }else{                $ ("#minute"). Text (Cminute );           }             if (Csecond <) {  &N Bsp             $ ("#second "). Text (csecond+ '. ') +MS);           }else{              $ ("#second"). Text (csecond+ '. ') +MS);           }       }   });    setTimeout ("Ti Ming () ", 100);}

JS countdown function source code

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.