ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
~~~ //生成随机数字或字母 var suijichars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']; var suijinums = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; suijishu = function(n, t) { var res = ""; for (var i = 0; i < n; i++) { if (t == 1) { var id = Math.ceil(Math.random() * 35); res += suijichars[id]; } else { var id = Math.ceil(Math.random() * 9); res += suijinums[id]; } } return res; } ~~~ ***** ~~~ //循环输出当前时间(到秒) tiaomiao = function(el) { //获得显示时间的div t_div = el; var now = new Date() //替换div内容 t_div.innerHTML = "现在是" + now.getFullYear() + "年" + (now.getMonth() + 1) + "月" + now.getDate() + "日" + now.getHours() + "时" + now.getMinutes() + "分" + now.getSeconds() + "秒"; //等待一秒钟后调用time方法,由于settimeout在time方法内,所以可以无限调用 setTimeout(time, 1000); } ~~~ ***** ~~~ //验证码倒计时 yzmdjs = function(el) { // 原生js版本 //<input id="send" type="button" value="发送验证码"> var times = 60, // 临时设为60秒 timer = null; el.onclick = function() { // 计时开始 timer = setInterval(function() { times--; if (times <= 0) { send.value = '发送验证码'; clearInterval(timer); send.disabled = false; times = 60; } else { send.value = times + '秒后重试'; send.disabled = true; } }, 1000); } } ~~~