This article will share with you a piece of example code to give you a detailed introduction to JavaScript to implement the SMS countdown 60s function. It is very good and has reference value. Friends who need it can refer to it.
No more nonsense, just give it to Everyone posted the code, the specific code is as follows;
$(function(){ //获取验证码 var getCode = document.getElementById('getCode'); var wait = 60; function time(btn){ if (wait===0) { btn.removeAttribute("disabled"); btn.innerHTML = "获取验证码"; wait = 60; }else{ btn.setAttribute("disabled",true); btn.innerHTML = wait + "秒后重试"; wait--; setTimeout(function(){ time(btn); },1000); } } getCode.onclick = function(){ time(this); }; })
Summary
The above is the detailed content of Example case of using JavaScript to implement SMS countdown of 60 seconds. For more information, please follow other related articles on the PHP Chinese website!