Jquery.fn explanation

Source: Internet
Author: User

Because of the study of jquery, superficial understanding is confused with JQuery.fn.extend (object) and Jquery.extend (object).

Here's a detailed explanation:

Jquery.extend (object); To extend the jquery class itself. Adds a new static method to the class;

JQuery.fn.extend (object); Add methods to jquery objects;

eg

$.extend ({

Add:function (a,b) {return a+b;}

});

Add a "static method" for jquery, and then you can use this method in the place where jquery is introduced,

$.add (3,4); Return 7

Jquery.fn = Jquery.prototype is equivalent to adding attributes to the jquery class. Just add "member functions" to the jquery class. Examples of jquery classes can use this "member function".

$.fn.close = function () {}

$.close = function () {}

The most obvious difference is when called:

$ (' #test '). Close () and $.close ();

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.