JQ 验证码倒计时
// 验证码 限制4位数 <div class="yam"> <input value="" oninput="if(value.length>4)value=value.slice(0,4);if(value<0)value=0" type="number" placeholder="验证码" /> <input style="background: #FFFFFF;color: #f2921b;" type="button" id="btn" value="获取验证码" onclick="Verification()" /> </div>
function settime(obj) { //发送验证码倒计时 if (countdown == 0) { obj.attr('disabled', false); //obj.removeattr("disabled"); obj.val("免费获取验证码"); countdown = 60; return; } else { obj.attr('disabled', true); obj.val("重新发送(" + countdown + ")"); obj.css({ color:'#bababa' }) countdown--; } setTimeout(function() { settime(obj) }, 1000) }
// 点击获取验证码 function Verification() { let html = $('#mobile').val() var obj = $("#btn"); settime(obj); console.log(html) }