(function ($) {/** * creates DOM * @param $this * @returns {boolean} */function createhtml ($this) { _init ($this); }/** * Initialize * @private * * function _init ($this) {}//public method var methods = {Init : function (initoptions) {options = $.extend ({}, $.fn.jquerypluginname.defaults, initoptions); var $this = $ (this); Return This.each (function () {createhtml ($this); }); }, Destroy:function () {return This.each (function () {}); }, Option:function (key, value) {if (arguments.length = = 2) return This.each (function ( {if (Options[key]) {Options[key] = value; } }); else return Options[key]; }}//The name of the plugin var methodName = "Jquerypluginname"; var options = {}; /** *Plugin entry */$.fn.jquerypluginname = function () {var method = Arguments[0]; if (Methods[method]) {method = Methods[method]; arguments = Array.prototype.slice.call (arguments, 1); } else if (typeof method = = = "Object" | |!method) {method = Methods.init; } else {$.error ("method (" + Method + ") does not exist on" + methodName); return this; } return Method.apply (this, arguments); } $.fn.jquerypluginname.defaults = {};}) (JQuery);
jquery-based plug-in architecture