<body>
<input type="button" id="btn" value="获取验证码" style="cursor: pointer" οnclick="getCode()"/>
<script>
function getCode(){
let btn=$("#btn");
btn.style.cssText = "opacity:.5;cursor:no-drop;";
btn.setAttribute("disabled", true);
let time = 6;
let setTime = setInterval(() => {
btn.value = `${--time}秒后重新获取`;
}, 1000);
setTimeout(() => {
this.returnCode = "000000"; //不重要
this.formValidate.code = this.returnCode; //不重要
btn.removeAttribute("disabled");
btn.style.cssText = "";
btn.value = "获取验证码";
clearInterval(setTime);
}, 6000);
}
</script>
</body>
点击按钮获取验证码倒计时
最新推荐文章于 2024-07-20 21:16:51 发布