When writing the registration page, it is sometimes necessary to send a registration message to obtain the verification code, but in order to prevent repeated sending of the message,
You must make the button available again after a period of time.
The code is as follows:
1 <HTML> 2 <Head>3 <MetaCharSet= "Utf-8">4 <title>Verification Code Button</title> 5 </Head>6 <Body>7 <Buttontype= "button"ID= "Send">Send Verification Code</Button>8 <Scripttype= "Text/javascript">9 wait= -;Ten functionWait_time (btn) { One if(Wait== 0) { A Btn.removeattribute ("Disabled"); - Btn.innertext= "Send Verification Code"; - wait= -; the } Else { - Btn.setattribute ("Disabled", true); - Btn.innertext=wait+"seconds after sending again"; - wait--; + SetTimeout (function() {wait_time (BTN);}, +); - } + } A document.getElementById ('Send'). onclick= function() {wait_time ( This)}; at </Script> - </Body> - </HTML>
JS implementation Send Verification Code Countdown button