js实现发送验证码倒计时

来源:互联网 发布:双色球算法公式2017 编辑:程序博客网 时间:2024/05/28 01:35
<!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" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><title>Document</title><script src="http://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script></head><body><button id="sendCaptcha">发送验证码</button><script type="text/javascript">var count;var t;function countdown(){if (count == 0) {$("#sendCaptcha").text("发送验证码");$("#sendCaptcha").removeAttr("disabled");clearTimeout(t);} else{$("#sendCaptcha").attr('disabled','disabled');$("#sendCaptcha").text('重新发送('+count+')');count--;setTimeout(countdown, 1000);}}$("#sendCaptcha").click(function(){count = 60;t = setTimeout(countdown, 1000);})</script></body></html>

0 0
原创粉丝点击