js 读秒
<input type="button" value=" 获取验证码 " class="verification right" ">
$(".verification").click(function(){ var nums = 20; var tel = $("#tel").val(); if(!is_mobile(tel)){ hint_msg('手机号码不正确'); return; }else{ $(".verification").css('border','1px solid #B7B2B2').css("background-color","#B7B2B2").prop('disabled',true); $(".verification").val(" "+nums+'秒后重试'+" "); var timer = setInterval(Byoyomi,1000); function Byoyomi() { nums--; if (nums > 0) { $(".verification").val(" "+nums+'秒后重试'+" "); } else { clearInterval(timer); //清除js定时器 $(".verification").css('background-color','#FF8000').css('border','1px solid #FF8000').prop('disabled',false); $(".verification").val(" "+"获取验证码"+" "); nums = 20; //重置时间 } } } });