input type="button" class="inpBtn" onclick="settime(this)" value="获取验证码" / /*-------------------------------------------------------------*/ //点击验证码的方法 var countdown = 60; function settime(obj) { if (countdown == 5
<input type="button" class="inpBtn" onclick="settime(this)" value="获取验证码" /> /*-------------------------------------------------------------*/ //点击验证码的方法 var countdown = 60; function settime(obj) { if (countdown == 59) { //发送验证码的主代码 } if (countdown == 0) { //点击后,过了60秒之后,恢复成获取验证码 obj.removeAttribute("disabled") obj.style.backgroundColor="#44aaff"; obj.value = "获取验证码"; countdown = 60; return; } else { //跳帧 0--->60 obj.setAttribute("disabled", true); obj.style.backgroundColor="#ccc"; obj.value = "重新发送(" + countdown + ")"; countdown--; } setTimeout(function() { settime(obj) }, 1000) } /*-------------------------------------------------------------*/