<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>js点击按钮后,倒计时N秒后才能再次点击提交</title>
</head>

<body>
<input type="button" id="btn" value="免费获取验证码" />

<script type="text/javascript">
var wait=60;
function time(o) {
        if (wait == 0) {
            o.removeAttribute("disabled");            
            o.value="免费获取验证码";
            wait = 60;
        } else {
            o.setAttribute("disabled", true);
            o.value="重新发送(" + wait + ")";
            wait--;
            setTimeout(function() {
                time(o)
            },
            1000)
        }
    }
document.getElementById("btn").onclick=function(){time(this);}
</script>
 


</body>
</html>

 

js点击按钮后,倒计时N秒后才能再次点击提交

 posted on 2013-11-12 15:25  纳米程序员  阅读(1062)  评论(0)    收藏  举报