JS Implementation Verification Code Countdown effect

Source: Internet
Author: User

Usually the registration page will have to get the Code button, and then click After 60 seconds to regain, such as now encountered in the project

Then click on the style, and the number is decremented, to 0 o'clock back to the original state ().

Construct the HTML structure first

<button class= "GetCode" > Get Verification Code </button>

CSS is a little bit

JS implementation:

var wait=60;        function Time (o) {            if (wait==0) {                o.removeattribute ("Disabled");                    O.innerhtml= "Input verification Code";                O.style.backgroundcolor= "#fe9900";                wait=60;            } else{                o.setattribute ("disabled", true);                o.innerhtml=wait+ "re-fetch after second";                O.style.backgroundcolor= "#8f8b8b";                wait--;                SetTimeout (function () {Time                    (o)                },1000)            }        }

Finally, click the button and call the time method:

$ (". GetCode"). Click (function () {Time            (this);        });

At this point all functions are complete.

JS Implementation Verification Code Countdown effect

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.