jquery source Learning (a) Core section

Source: Internet
Author: User

This part is at the heart of jquery.

    1. jquery's constructor
    2. The core tool function of jquery

Constructors

function (Selector, context) {    // The JQuery object is actually just the Init constructor ' enhanced '     //  need init if jQuery is called (just allow error to being thrown if not included)    return
     New  jQuery.fn.init (selector, context);}

As shown in the code, the JQuery object is actually an instance of JQuery.fn.init

JQuery.fn.init is not available in the core module of jquery and will be explained in the next module

Sort out a functional approach to the core part of jquery

Presentation method: $ refers to the jquery class

$.fn refers to the jquery object

Built-in methods for jquery objects

$.fn.toarray () Convert a jquery object to an array object
$.fn.get () Returns a DOM object, with no arguments or null arguments, and the return value is the same as the ToArray () method
$.fn.pushstack (Elems) Pushes an array of arguments into the stack and caches the elements
$.fn.each (Callbak) Loop, return False in callback, break loop
$.fn.map (callback) Loop that returns an array of callback return values
$.fn.slice (Start,end) To intercept a jquery object in an index value
$.fn.first () Gets the first in a jquery object
$.fn.last () Gets the last one in the jquery object
$.fn.eq (Index) Gets the object of the index position in the jquery object
$.fn.end () Get the previous jquery object within the jquery internal stack
$.fn.extend (obj) Append obj to jquery's prototype chain, primarily for jquery plugin notation

  

  

    

    

  

    

The built-in methods provided by the JQuery class

$.extend (obj) Append obj to the jquery class, mainly for jquery plugin notation
$.extend (TARGET,OBJ1....OBJN) Append OBJ1,OBJN to target, default shallow copy
$.extend (DEEP,TARGET,OBJ1....OBJN) The first parameter is a Boolean value that sets a deep copy (true) shallow copy (false)
$.error (msg) Throw exception//new Error (msg)
$.isfunction (obj) Determine if obj is a function
$.isarray (arr) Determine if arr is an array
$.iswindow (obj) Determine if obj is a Window object//obj! = null && Obj.window = = = Window
$.isnumeric (obj) To determine if obj is a number, obj can be a number of numbers, and returns False when Obj is Nan or infinitely large
$.isplainobject (obj) Determines if obj is a purely object, created by {} or New object ()
$.isemptyobject (obj) Determines if obj is an empty object, detects the prototype chain, and returns true if the argument is an empty array
$.type (obj) Returns the type of obj,Boolean number string function array date RegExp object error
$.globaleval (Code) Executing code,eval (code) under the global scope executes under the current scope
$.nodename (Elem,name) Determines whether the node name of the Elem is name and the return value is boolean,elem as a DOM element
$.each (Obj,callbak) return false in loop Obj,callback, break loop
$.trim (str) Remove the spaces on both STR and return "" when the parameter is null and undefined
$.inarray (Elem,arr,index) Retrieves the location of the Elem element in arr, starting at index position, finds the first post-return position, does not find return-1, and finds it by default starting with 0
$.merge (First,second) Merges two arrays, appends the second array to the first array, and changes the first array
$.grep (ELEMS,CALLBACK,FLG) Finds an array element that satisfies the filtering function. The original array is unaffected. FLG default to False
$.map (Obj,callback) Loop obj, which returns an array of callback return values
$.now () Returns the number of milliseconds for the current system time.
$.proxy (Function,context) Accepts a function and then returns a new function, and the new function always retains a specific context context.

    

        

      

 

    

The following method is found in the source code, the comments are displayed as jquery internal use, is not yet clear use, waiting for further study

$.noop ()

$.support

$.camelcase

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.