JS 60秒后重发送验证码

来源:互联网 发布:license 开发 node 编辑:程序博客网 时间:2024/06/08 06:57
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Document</title></head><body><button id="getPhoneCode"></button><script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script><script>function settime($obj,time){if(time==0){$obj.attr("disabled",false);$obj.css("background","#f38401").css("cursor","pointer");$obj.text("获取手机验证码");return;}else{$obj.attr("disabled",true);$obj.css("background","#ccc").css("cursor","noe-allowed");$obj.text("重新发送("+time+")");time--;}setTimeout(function(){settime($obj,time)},1000);}settime($("#getPhoneCode"),60);</script></body></html>