• js组件常用封装方法。。。。。【组件封装】 ★★★★★★ 1月会员日 集人气【弹窗】


    公共弹窗js写法:mcake弹窗封装Dialog.js

    function Dialog(bg,els,opts) {
        this.$els = $(els);
        this.$Dialogbg = $(bg);
        this.$close = this.$els.find(opts.close);
        this.$btn = this.$els.find(opts.btn);
        this._init();
    }
    Dialog.prototype={
        _init:function () {
            var self = this;
            this.show();
            this.$Dialogbg.click(function () {
                self.hide();
            });
            this.$close.click(function () {
                self.hide();
            });
            this.$btn.click(function () {
                self.hide();
            });
        },
        show:function () {
            this.$Dialogbg.fadeIn(300);
            this.$els.fadeIn(300);
        },
        hide:function () {
            this.$Dialogbg.fadeOut(300);
            this.$els.fadeOut(300);
        }
    };
    
    /*实例化*/
    new Dialog(".Dialogbg",'.DialogBox',{
        close:'.closes',
        btn:'.go-use'
    });

     

  • 相关阅读:
    寒假学习进度7
    寒假学习进度3
    寒假学习进度6
    寒假学习进度5
    寒假学习进度8
    加分项
    每日博客
    每日博客
    每日博客
    每日博客
  • 原文地址:https://www.cnblogs.com/shimily/p/12058664.html
Copyright © 2020-2023  润新知