zoukankan      html  css  js  c++  java
  • 验证码倒计时

    <input id="send" type="button" value="发送验证码">

    js

    var times = 60, // 时间设置60秒
    
     timer = null;
    
    document.getElementById('send').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);
    
    }

    jq

    var times = 60,
    
        timer = null;
    
    $('#send').on('click', function () {
    
        var $this = $(this);
    
        // 计时开始
    
        timer = setInterval(function () {
    
            times--;
    
            if (times <= 0) {
    
                $this.val('发送验证码');
    
                clearInterval(timer);
    
                $this.attr('disabled', false);
    
                times = 60;
    
            } else {
    
                $this.val(times + '秒后重试');
    
                $this.attr('disabled', true);
    
            }
    
        }, 1000);
    
    });
  • 相关阅读:
    nginx特性
    mysql增删改查
    keepalived+nginx集群
    nginx+tomcat集群方法
    jdk环境配置(Windows)
    nginx_http核心模块(二)
    nginx入门手册(一)
    nginx 配置文件解析(一)
    tcpdump用法
    Tcpdump.
  • 原文地址:https://www.cnblogs.com/sjw-dmwz/p/9066117.html
Copyright © 2011-2022 走看看