js 短信倒计时60s
JS 短信 倒计时
2023-09-14 09:06:33 时间
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <style> #getCode { width: 9rem; height: 3rem; line-height: 3rem; font-size: 1.2rem; background-color: #3a3a3a; color: #fff; border-radius: 0.8rem; border: none; text-align: center; } #getCode[disabled] { background-color: #B6B6B6; } </style> <body> <button id="getCode">获取验证码</button> </body> <script src="https://cdn.bootcss.com/jquery/1.7.2/jquery.min.js"></script> <script> $(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); }; }) </script> </html>
相关文章
- 原生Js_实现广告弹窗
- js表单动态添加数据并提交
- 关于webview调用js出现has no method 'toString'
- js之正则表达式详解
- js获取select改变事件
- [Node.js] Level 3 new. Steam
- js对select动态添加和删除OPTION
- [Immutable.js] Updating nested values with ImmutableJS
- SAP UI5框架 component.js的加载原理
- 华为OD机试 - 最多获得的短信条数、云短信平台优惠活动(Java & JS & Python)
- JS的文本同步框
- js 更改对象属性名
- 【华为OD机试 2023】垃圾短信识别(C++ Java JS Python)
- 【JavaScript】JS读取XML文件并进行搜索
- JS从0到1——753. 平方矩阵 I