JS native code Countdown snapping

Source: Internet
Author: User
Tags jquery library

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

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.