jquery Plugin pre-development Preparation (iv)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.