<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<input type="button" name="" id="get" value="获取" onclick="getting()" />
<span id="a"></span>
<script>
var load = false
function getting() {
if (!load) {
var num = 60 //倒计时为60秒
document.getElementById('get').disabled = true
document.getElementById('get').value = "获取中" //将按钮内的文字变为获取中
document.getElementById('a').innerText = num + "秒后重获验证码" //显示验证码
var codeTimer = setInterval(function() {
if (num == 1) {
clearInterval(codeTimer)
document.getElementById('a').innerText = ""
document.getElementById('get').disabled = false
document.getElementById('get').value = "获取"
} else {
num--
document.getElementById('a').innerText = num + "秒后重获验证码"
}
}, 1000) //倒计时
}
}
</script>
</body>
</html>