jquery Plugin pre-development preparation (II)

Source: Internet
Author: User

In the previous section we have used $.fn.myplugin to extend a method to jquery, while also ensuring that the chained invocation of jquery has not been compromised. The attentive little companions may have noticed that in the $.fn.myplugin method we used the constructor to generate an object, as follows:

In fact, we really implement our own plug-in code is written in the Myplugin constructor, so the benefit is that when we use the $ (selector). Myplugin (Options), the following actions are performed:

(1) Select the current element and read the Myplugin attribute under the current element;

(2) Determine whether the attribute book exists, if there is a step (4), if there is no step (3);

(3) When there is no myplugin attribute under the element, instantiate a Myplugin object and save the object under the selected element;

(4) Determine the parameters of the Myplugin, if it is a string type, then invoke the method under the instance.

jquery Plugin pre-development preparation (II)

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.