zoukankan      html  css  js  c++  java
  • jQuery 插件格式

    (function (factory) {
      if (typeof define === 'function' && define.amd) {
        define(['jquery'], factory);
      } else {
        factory(jQuery);
      }
    }(function ($) {

      function myShowOrHide($element, options) {
        this.$element = $element;
        this._defaults = {
          size: 3,
          status: 'hide'
        };
        this.options = $.extend({}, this._defaults, options || {});
        this.init();
      }

      myShowOrHide.prototype = {
        init: function () {

        },
        soh: function () {

        }
      }
    };

    $.fn.myShowOrHide = function (options, param) {
      return this.each(function () {
        var instance;
        instance = $.data(this, 'myShowOrHide');
        if (!instance) {
          instance = new myShowOrHide(this, options);
          $.data(this, 'myShowOrHide', instance);
        }
        if ($.type(options) === 'string') {
          return instance[options](param);
        }
      });

    }

    return this;
    }));

  • 相关阅读:
    典型漏洞归纳之上传漏洞
    典型漏洞归纳之解析漏洞
    Python学习目录
    MySQL数据库优化的八种方式
    深度剖析Flask上下文管理机制
    算法十大排序(含动图)
    设计模式代码实例
    设计模式
    数据结构
    算法基础
  • 原文地址:https://www.cnblogs.com/zhoujiahong/p/11612435.html
Copyright © 2011-2022 走看看