Jquery 实现按钮发送验证码倒计时功能
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>按钮倒数5秒后才能点击</title>
</head>
<script src="js/jquery-1.10.2.js"></script>
<body>
<input type="button" value="发送验证码" id="button" onclick="setTime()">
</body>
<script type="text/javascript">
var i = 0;
var timehwnd =null;
function setTime(){
i=5;
$("#button").attr("disabled","false");
timehwnd = setInterval("Countdown()",1000);
}
function Countdown(){
i--;
if(i == 0){
$("#button").val("发送验证码");
$("#button").removeAttr("disabled");
clearInterval(timehwnd);
}else{
$("#button").val("重新发送("+i+")");
} }
</script>
</html>

QQ截图20190613112448.png

QQ截图20190613112457.png
本文标题:Jquery 实现按钮发送验证码倒计时功能
本文链接:https://www.haomeiwen.com/subject/kfmjfctx.html
网友评论