The page needs to make a countdown function, and then the Niang again, find two ways of writing, the original JS and JQ, after testing the native JS in IE may not refresh the phenomenon so combined with a great god of the JQ wording modified one.
Native JS notation:
Html:
<Divclass= "Time"> <spanID= "T_d"></span> <spanID= "T_h"></span> <spanID= "T_m"></span> <spanID= "t_s"></span></Div>
Js:
<script>functionGetrtime () {varEndtime=NewDate (' 2015/06/19 22:00:00 ')); varNowtime =NewDate (); varT =endtime.gettime ()-Nowtime.gettime (); varD=math.floor (t/1000/60/60/24); varH=math.floor (t/1000/60/60%24);varM=math.floor (t/1000/60%60); varS=math.floor (T/1000%60);document.getElementById ("T_d"). InnerHTML =D + "Day"; document.getElementById ("T_h"). InnerHTML =H + "when"; document.getElementById ("T_m"). InnerHTML =m + "min"; document.getElementById ("t_s"). InnerHTML =s + "seconds"; } setinterval (Getrtime,0);</script>
This kind of writing, JS part is easy to read.
Combined with JQ modified version:
The HTML section is the same as above, mainly the JS section:
<script type= "Text/javascript" >varEndtime=NewDate (' 2015/06/19 22:00:00 '));varNowtime =NewDate ();varT =endtime.gettime ()-nowtime.gettime ();varIntdiff = parseint (t/1000);//Countdown total number of seconds, because it is in milliseconds, so divided by 1000 is the secondfunctionTimer (Intdiff) {Window.setinterval (function(){ varDay=0, hour=0, Minute=0, Second= 0;//Time Default Value if(Intdiff > 0) { Day= Math.floor (Intdiff/(60 * 60 * 24)); Hour= Math.floor (Intdiff/())-(Day * 24); Minute= Math.floor (INTDIFF/60)-(Day *)-(Hour * 60); Second= Math.floor (Intdiff)-(Day *)-(Hour *)-(MINUTE * 60); } if(Hour <= 9) hour = ' 0 ' +hour; if(minute <= 9) minute = ' 0 ' +minute; if(Second <= 9) Second = ' 0 ' +second; $(' #t_d '). html (day+ "days")); $(' #t_h '). html (hour+ ' time '); $(' #t_m '). html (minute+ ' points ')); $(' #t_s '). HTML (second+ ' s ')); Intdiff--; }, 1000);} $(function() {timer (intdiff);});</script>
The notation of JS and JQ Countdown