验证码按钮点击后效果

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>无标题文档</title> 
<script type="text/javascript" src="js/jquery.js"></script> 
</head> 
<body> 
<input type="button" id="btn" value="免费获取验证码" onclick="settime(this)" /> 
<script type="text/javascript"> 
var countdown = 60;
function settime(btn) {
    if (countdown == 0) {
        btn.removeAttribute("disabled");
        btn.innerHTML = "免费获取验证码";
        countdown = 60;
        return;
    } else {
        btn.setAttribute("disabled", true);
        btn.innerHTML = "重新发送(" + countdown + ")";
        countdown--;
    }
    setTimeout(function () {
        settime(btn)
    }, 1000)
}
</script> 
</body> 
</html>

 

posted @ 2017-09-25 14:25  守y1座_空城  阅读(137)  评论(0编辑  收藏  举报