After clicking the button in jquery, the countdown is 60 seconds before you can click Send again.

Source: Internet
Author: User

This article will introduce you to the question that after clicking the button in jquery, the message sending effect can be clicked 60 seconds after the countdown. For details, refer.

Example

The Code is as follows: Copy code

<Input type = "button" id = "btn" value = "get verification code for free"/>

<Script type = "text/javascript">
Var wait = 60;
Function time (o ){
If (wait = 0 ){
O. removeAttribute ("disabled ");
O. value = "get verification code for free ";
Wait = 60;
} Else {
O. setAttribute ("disabled", true );
O. value = "resend (" + wait + ")";
Wait --;
SetTimeout (function (){
Time (o)
},
1000)
}
}
Document. getElementById ("btn"). onclick = function () {time (this );}
</Script>

Or write it like this.

The Code is as follows: Copy code

<Input type = "button" id = "btn" value = "get verification code for free" onclick = "settime (this)"/>
<Script type = "text/javascript">
Var countdown = 60;
Function settime (val ){
If (countdown = 0 ){
Val. removeAttribute ("disabled ");
Val. value = "get verification code for free ";
Countdown = 60;
} Else {
Val. setAttribute ("disabled", true );
Val. value = "resend (" + countdown + ")";
Countdown --;
}
SetTimeout (function (){
Settime (val)
}, 1000)
}
</Script>


For more information about js countdown, see

The Code is as follows: Copy code

<Script>
I = 9
Function change ()
{
I --;
P. value = "agree" + I
If (I = 0)
{P. disabled = false}
Else
SetTimeout ("change ()", 1000)
}
Window. onload = change;
</Script>
<Input type = button name = p disabled> </font>
<A href = "http://www.bKjia. c0m/"> enter 111cn </a>

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.