zoukankan      html  css  js  c++  java
  • 学习写了一个点击按钮倒计时的jquery小插件

    (function($) {
        $.fn.extend({
            getSms: function(value) {
                value = $.extend({
                    wait: 60, //参数, 默认60秒
                }, value);
                var id = $(this).attr('id');
                var wait = value.wait;
                //内部函数
                function time(id) {
                    console.log(wait);
                    if (wait == 0) {
                        $("#" + id).removeAttr("disabled");
                        $("#" + id).val('获取验证码');
                        wait = value.wait;
                    } else {
                        $("#" + id).attr("disabled", "true");
                        $("#" + id).val("重新发送(" + wait + ")");
                        wait--;
                        setTimeout(function() {
                            time(id)
                        }, 1000)
                    }
                }
                $(this).click(function() {
                    time(id);
                })
            }
        });
    })(jQuery);
    

      

    前端页面用的时候

    $("#getsmsbtn").getSms({wait:60});//参数默认60 可以省略
    

      

  • 相关阅读:
    数据结构
    java web
    C++
    SQL(结构化查询语言)
    网站协议
    python
    爬虫
    select 多选
    List 去除重复数据的五种方式
    oracle锁表SID查询
  • 原文地址:https://www.cnblogs.com/freespider/p/3686165.html
Copyright © 2011-2022 走看看