Home >Web Front-end >JS Tutorial >js implements SMS verification code countdown function
This article mainly shares with you js to implement the SMS verification code countdown function. I hope it can help everyone.
js part
<script type="text/javascript"> var countdown=60; function settime(obj) { if (countdown == 0) { obj.removeAttribute("disabled"); obj.value="免费获取验证码"; countdown = 60; return; } else { obj.setAttribute("disabled", true); obj.value="重新发送(" + countdown + ")"; countdown--; } setTimeout(function() { settime(obj) } ,1000); } function dd(){ var obj = document.getElementById("test1"); obj.innerHTML=""; var nullOp = document.createElement("option"); nullOp.setAttribute("value", ""); nullOp.appendChild(document.createTextNode("请选择")); obj.appendChild(nullOp); for ( var int = 0; int < 1; int++) { var op = document.createElement("option"); op.setAttribute("value", "123"); op.appendChild(document.createTextNode("123")); obj.appendChild(op); } }); </script> html部分 <input type="button" id="btn" value="免费获取验证码" onclick="settime(this)" /> <input type="text" id="dd" onclick="dd()" value="sdf" />
Related recommendations:
How to use php to send SMS verification codes、
JS implementation SMS verification code
The above is the detailed content of js implements SMS verification code countdown function. For more information, please follow other related articles on the PHP Chinese website!