• 验证码倒计时js



    getVarify.js

    
    // 验证码计时——第一种
    window.onload = function () {
        var send = document.getElementById('send'), //按钮ID
            times = 10, // 别忘了改这里
            timer = null;
        send.onclick = function () {
            // 计时开始
            send.disabled = true;
            timer = setInterval(function () {
                times--;
                if (times <= 0) {
                    send.value = '获取验证码';
                    clearInterval(timer);
                    times = 5;  // 别忘了改这里
                    send.disabled = false;
                } else {
                    send.value = times + '秒后重试'
                    send.disabled = true;
                } console.log(times)
            }, 1000);
            // 发送请求获取验证码
            console.log("sending...")
        }
    }// 验证码计时——第二种
    // 参数:倒计时秒数, 按钮jquery对象, 倒计时结束时显示的文字
    // 可以放到短信发送完毕后的回调函数里
    // switchMSG(60, $("#get-verify"), '获取验证码')
    function switchMSG(times, ele, txt) {
        ele.prop('disabled', true)
        var idT = setInterval(function() {
            if(times < 1) {
                ele.html(txt)
                ele.prop('disabled', false)
                clearInterval(idT)
            } else {
                ele.html(times+'s')
                times--
    
            }
        }, 1000)
    }
    
    
  • 相关阅读:
    日程管理APP测试用例
    日程管理APP的测试计划和测试矩阵
    Bug report——仿网易新闻APP
    NABCD模拟实验
    5w1h

    小组作业
    code review
    Mutual review
    阅读思考
  • 原文地址:https://www.cnblogs.com/lovellll/p/10206274.html
Copyright © 2020-2023  润新知