var timer=60;
Var t=null;
Var sent=document. QuerySelector (' sent ');
Sent. AddEventListener (' click ', function () {
Sent. Disable=true;
ClearInterval (t);
T=setInterval (function () {
If (timer==0) {
ClearInterval (t);
Sent. Disable=false;
Sent. InnerHTML='send verification code;
The timer=60;
} else {
Sent the innerHTML='left' + timer + 'seconds';
The timer -;
}
}, 1000);
})
This is a button:
& lt; The button & gt; Send verification code & lt;/button>
CodePudding user response:
Have form form, the button with type="button" or it will default as the submit form is submitted