jquery source ——— Methods and properties

Source: Internet
Author: User
Not updated for a while, today summarize some of jquery's methods and properties one, JQ methods and properties of the overall structure (91 lines--281 line)
Jquery.fn = Jquery.prototype = {

            jQuery: Version

            constructor: fix points to problem

            init (): Initialization and parameter Management

            selector: Storing selection strings

            Length:this object's length

            ToArray (): To the array get (): to

            the native collection

            pushstack (): JQ object's Stack each

            (): Traverse collection

            Ready (): Dom Loaded Interface

            slice (): Intercept of the collection first (): The Last () of the collection (): The final eq () of the collection ():

            The specified map () of the collection:

            returns the new collection End

            ( ): Returns the previous state

            push (): (used)

            sort (): (internal use)

            splice (): (internal use)
    }
Second, JQ methods and attributes of the detailed

1. Properties:

Jquery:core_version,//Storage JQ version

constructor:jquery,  ///point constructor to JQuery

2. Init method

Initial or JQ, matching JQ selector

Init:function (selector, context, rootjquery) {
   //Process Code
}

The JQ selector is written in a few ways:

Tag Class name selection: $ ("#div") $ (". Div") $ ("div") $ (". Div #p")

Create element: $ ("<li>") $ ("<li>111</li>")

object This, Doc Select: $ (this) $ (document)

function: $ (function () {})

type selection: $ ([]) $ ({})

(1) $ (""), $ (null), $ (undefined), $ (false) condition

When we look at the JQ source, we first see two declared variables in the Init method, and second we see the following code in lines 106 to 108:

if (!selector) {return this
    ;
}

This is mainly selected as $ (""), $ (null), $ (undefined), $ (false)
These kinds of.

The key content here is the THIS,JQ which has been dealt with in this process, what kind of processing, such processing:

$ ("div") as this
= {
  0: ' div ',
  length:1, context
  :   //Optional
}

How to do it, we have mentioned earlier: it is the following code implementation

JQuery = function (selector, context) {return to
        new JQuery.fn.init (selector, context, rootjquery);

(2) $ ("<div>") $ ("<div></div>") $ ("#div")
Next we can see a second Judge 111--176 line

 if (typeof selector = = "string") {} 

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.