Function display:
1. Click the button,
2. Start the countdown
3. Restore to 60 after reaching 1
<! DOCTYPE html> <html> <head lang="en">
<meta charset="UTF-8"> <title> 60-second countdown </title> </head> <body> <input id="get_pass" type="button" value="Obtain captcha code" onClick="click1()">
</body>
</html>
<script language="javascript">
var j = function () {
return document.getElementById("get_pass");
};
var number = 60;
function click1() {
j("get_pass").value = number + "Seconds"; number = number - 1; // When the count is 0, restore the content and set number=60if (number < 0) {
j("get_pass").removeAttribute("disabled");
j("get_pass").value = "Obtain captcha code"; number = 60; // Restore number to 60}else {
j("get_pass").setAttribute("disabled".false);
setTimeout("click1()", 1000);
}
}
</script>Copy the code