Through the above three summary of the comb, and finally a summary, the plug-in general form into a template, for repeated calls.
(function($) { varMyplugin = (function() { functionmyplugin (element, Options) {//deep copy of User Configuration items and default options this. Settings = $.extend (true, $.fn. myplugin.defaultvalue, Options | | {}); this. Element =element; this. Init (); } Myplugin.prototype= { //Initializing Plug-insInit:function() { var_this = this; }, //draw the DOM structure_initdom:function() { } }; //The object must be returned returnmyplugin; })(); $.fn. Myplugin=function(options) {return this. each (function() { var_this = $ ( this), //reads an instance from under the current objectInstance = _this.data (' myplugin ')); //If no instance creates a new if(!Instance) { //creates a new instance, _this represents the currently selected element, and options represents the configurationInstance =NewMyplugin (_this, options); //Save the current instance to data_this.data (' Myplugin ', instance); } if($.type (options) = = = ' String ') { returninstance[options] (); } }); }; //Default Parameters$.fn. Myplugin.defaultvalue ={value1:' 1 ', Value2:' 2 ', Value3:' 3 ', Value4:' 4 ' };}) (jQuery);
jquery Plugin pre-development Preparation (iv)