Learning Summary: jquery plugin development model and structure

Source: Internet
Author: User

Learn Blog Links:

①https://www.cnblogs.com/cyStyle/

② https://www.cnblogs.com/chengyunshen/p/7277305.html

③ https://www.cnblogs.com/sjqq/p/6410839.html

< The development of the span class= "ql-author-11805412" >jquery plugin includes two types:

< Span class= "ql-author-11805412" to (1) class-level plug-in development, which adds new global functions to jquery, the global function of jquery is a function that belongs to the jquery namespace, which is equivalent to adding a method to the jquery class itself.

< Span class= "ql-author-11805412" >

< Span class= "ql-author-11805412" > (2) object-level plug-in development, adding methods to jquery objects.

The big guy's experience (first link):

(1) Put all the code in the closure (the closure is equivalent to a private scope, external access to internal information, and there is no global variable pollution)

(2) provides default parameter options for plug-ins

(3) traversing multiple elements and returning (sizzle selector engine, chained call)

(4) One-time code is placed outside the main loop

(5) defining public and private methods (increasing the robustness of the code)

(function($) {    /// within the plug-in container, define a private method    function// code here//var methods = // code here };}) (jQuery);           

(6) Add persistent data ($.data function adds information to element), $.removedata function to delete corresponding data

Learning Summary: jquery plugin development model and structure

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.