Just used a little time to perfect the countdown to buy the function to do again, this is used in the original sound code, did not introduce the jquery library, although the obvious sense of native code to more, but write a small function or a sense of accomplishment. Need to pay attention to is the code order execution problem, must be clear-minded. Otherwise the code order is wrong, some functions can not be realized.
learned that the original JS changed input disabled attribute value, because want to let the countdown to the end of the same time, snapping button can be clicked. The code is: document.getElementById ("buy"). Disabled = "", or the value of disabled can be false.
Here is the code I wrote, where not perfect, but also ask the big God pointing.
1<! DOCTYPE html>234<meta charset= "UTF-8" >5<title> Countdown Snapping </title>67<body>8<span id= "Time" ></span>9<input type= "button" value= "Start snapping" id= "buy" disabled= "true" >Ten<script> One functionTime () { A varDate =NewDate (); - varNowhour =date.gethours (); - varNowmin =date.getminutes (); the varNowsec =date.getseconds (); - varFinalhour = 22; - varFinalmin = 22; - varFinalsec = 22; + varFinals = Finalhour * 3600 + finalmin * 60 +finalsec; - varnows = nowhour * 3600 + nowmin * 60 +nowsec; + varShowhour = parseint ((finals-nows)/3600); A varShowmin = parseint ((finals-nows)%3600/60); at varShowSec = (finals-nows)%60; - if(showsec<10){ -ShowSec = "0" +showsec; - } - if(showmin<10){ -Showmin = "0" +showmin; in } - if(showhour<10){ toShowhour = "0" +Showhour; + } -document.getElementById ("Time"). InnerHTML = "Distance 22 points 22 minutes 22 seconds also:" + Showhour + ":" + showmin + ":" +showsec; the if(Showhour = = "XX" && showmin = = "XX" && showsec = = "00"){ * clearinterval (t); $document.getElementById ("buy"). Disabled= "";Panax Notoginseng } - } the Time (); + vart = setinterval (time,1000); A</script> the</body> +JS native code Countdown snapping