jquery Source Code Analysis-03 constructs jquery objects-source code structure and core functions

Source: Internet
Author: User

3. Construct a jquery object

3.1 Source structure

First look at the overall structure, then do the decomposition:

(function(window, undefined) {varJQuery = (function() {       //Building a jquery object       varJQuery =function(Selector, context) {return NewJQuery.fn.init (Selector, context, rootjquery); }          //jquery Object PrototypesJquery.fn = Jquery.prototype ={constructor:jquery, init:function(selector, context, rootjquery) {//Selector has the following 7 branching conditions:              //DOM Element              //Body (optimized)              //strings: HTML tags, html strings, #id, selector expressions              //function (as ready callback function)              //finally returns a pseudo-array           }       }; //Give the init function The JQuery prototype for later instantiationJQuery.fn.init.prototype =Jquery.fn; //merge content into the first parameter, most of the subsequent functions are extended through the function       //with JQuery.fn.extend extended functions, most will call functions with the same name extended by Jquery.extendJquery.extend = JQuery.fn.extend =function() {}; //extending the static method on jqueryJquery.extend ({//Ready Bindready           //Isplainobject Isemptyobject           //Parsejson Parsexml           //Globaleval           //Each makearray inArray merge grep map           //Proxy           //Access           //Uamatch           //Sub           //Browser       }); //here, the jquery object is constructed, and the code behind it is an extension of the jquery or jquery object.       returnJQuery;       })(); Window.jquery= window.$ =jQuery;}) (window);

jquery Source Code Analysis-03 constructs jquery objects-source code structure and core functions

Related Article

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.