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;
}));