倒计时
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>title</title>
<script src="jquery.min.js"></script>
</head>
<body>
<input type="number" class="number">
<input type="button" class="btn" id="btn" value="获取验证码">
<script>
var obtn = document.getelementbyid("btn")
function getcode() {
var num = 30;
var timer = setinterval(function () {
num--
$(".btn").val(num+ ' 秒后重新获取');
if(num==0){
clearinterval(timer)
// debugger;
$(".btn").val("重新获取");
obtn.addeventlistener("click",getcode)
}else{
obtn.removeeventlistener('click', getcode);
}
},1000)
}
obtn.addeventlistener("click",getcode)
</script>
</body>
</html>
上一篇: 宝宝起皮疹不等于药物过敏
下一篇: 感冒、流感、禽流感区别