A: $ (selectorstr[, limit Range]), accepts a selector (a string that conforms to the jquery specification), and returns a JQuery object;
Two: $ (htmlstr[, Document Object]), $ (Html[,json object]) passing in an HTML string, creating a new DOM element
Three: $ (DOM Element), $ (collection of DOM elements) converts DOM elements into jquery objects.
Four: $ (custom object) encapsulates an ordinary object as a jquery object.
Five: $ (callback function) binds the Ready event listener function to execute when DOM loading is complete.
Six: $ (jquery object) accepts a jquery object and returns a copy of a jquery object
Seven: $ () creates an empty jquery object.
1 // $ (selector[, limit Range]) 2 $ (". Guo"). Click (function () {/// There is no context parameter 3this ). css ({" Color ":" Red "}); // This is the context parameter for scoping 4 });
When a string is passed in, the constructor determines whether it is a selector string or an HTML string.
If it is a selector string: Traverse the DOM to find the element that matches it, and if there are no matching elements,
Returns an empty jquery object, otherwise the matching elements are created to a jquery object.
1 // $ (htmlstr[, Document Object]) 2 // Simple label: No tape node
The jquery constructor creates a DOM node using JS's original ecological Method Document.createelement ()
// Complex Tags: contains child nodes.
jquery uses the document fragment Buildfragment () method to insert all child nodes into the [, document Object] all at once.
If it is not specified here, it is the document;
$ (Html[,json object])
When HTML is a simple tag, then her second argument can be a JSON object that contains the properties or events of the DOM element.
1 // $ (Html[,json object]) 2 $ ("<div></div>", {3 /// because class is a keyword for JS, so quote 4 text: "Everyone good",5 function () {alert ("What do I Do");} 6 }). Append ("Body");
$ (Element) or $ (elements)
Pass in a DOM object or a set of Dom objects
1 ("Div.guo"). Click (function () {2 $ (this). Slideup (); 3 });
$ (object);
Pass in an ordinary object
var obj = {name: "Guo", age:24 }; var $obj = $ (obj); $obj. On (function () { alert ("Set up a custom event"); }); $obj. Trigger ("Guo");
$ (callback) to pass in a function
$ (function () {})
This represents the execution of the function after the DOM has been loaded.
$ (jQuery Object);
When a jquery object is passed in, a copy of the jquery object is created and returned, and the copy is referenced exactly to the same DOM object as the incoming jquery object.