js实现手机验证码
点击按纽实现倒计时
·
<!DOCTYPE html>
<html>
<body>
<input type="button" value="点击发送" onclick="settime(this)" />
<script>
var countdown = 30;
function settime(obj) {
if (countdown === 0) {
obj.removeAttribute("disabled");
obj.value="点击发送";
countdown = 30;
return;
} else {
obj.setAttribute("disabled", true);
obj.value = "重新发送(" + countdown + ")";
countdown--;
}
setTimeout(function() {
settime(obj)
},1000)
}
</script>
</body>
</html>
更多推荐
已为社区贡献1条内容
所有评论(0)