jQuery function object (a)

A, jQuery function
two forms of jQuery function:
. 1, jQuery ()
2, $ ()
Description:
in jQuery using jQuery () and $ () is the equivalent , are generally used $ ()

jQuery function four kinds of parameters can be stored in the form: [ returns are jQuery object ]
1, $ (selector string)    
jQuery function acquired by a respective DOM object corresponding to the selector, and then to package these DOM object and returns a jQuery
eg:

    var $ div = $ ( 'div');  // Select all div element nodes and returns these packaged into a DOM node object jQuery


2, $ (DOM object) (i.e. Node Examples )
jQuery function package as the DOM object and returns jQuery object
eg:

    var div = document.getElementsByTagName ( 'div' );
     var $ $ = div (div);     // The DOM object into the object jQuer


3, $ (HTML text string)
jQuery function creates good HTML elements according to incoming text and packaged as jQuery object return
eg:

    var $ div = $ ( "<div class = 'one'> one <div>");     // create a tag called div class one and encapsulates it into a jQuery object and returns


4, $ (anonymous function)
when the structure of the document is loaded jQuery function calls anonymous function
eg:

    $ ( Function () {});     // document structure function in the function execution code loaded after 
    $ (document) .ready ( function () {});   // the document object nodes into the call object jQuery ready ( ) method to perform functions within the document to load before the code


Two, [jQuery object is generally added before the variable is used to indicate that it is $ jQuery object ]
1, the number of instructions jQuery object
A, the object is an instance of jQuery jQuery function, he can call methods defined jQuery prototype
B, jQuery the object is a class object is an array element is stored inside the DOM object
C, the object is typically acquired using jQuery selector to obtain [ eg: $ (selector string) ]
d, the operation jQuery object is actually an array of jQuery DOM objects in batch operation

2, interconversion between the DOM objects jQuery object
a, object into a DOM object jQuery
eg:

    $ ( 'div') [0];     // Add the numerical subscripts after the DOM jQuery object to select the object whose class acquired JQuery array of objects stored in the corresponding position


b, DOM object into the object JQuery
eg:

    var div = document.getElementsByTagName ( 'div');     // plurality div class returns an array of DOM objects 
    var $ $ = div (div);     // The jQuery DOM object as a parameter to a function of the DOM object into a jQuery object

 

Guess you like

Origin www.cnblogs.com/nzcblogs/p/11256902.html