One: $ (selectorstr[, restricted Range]), accepts a selector (a string that conforms to the jquery specification), returns a JQuery object;
Copy Code code as follows:
$ (selector[, restricted range])
$ (". Guo"). Click (function () {//There is no context parameter here
$ ("A.aguo", this). css ({"Color": "Red"});//this is the context parameter for scoping
});
Two: $ (htmlstr[, Document Object]), $ (Html[,json object]) passing in an HTML string, creating a new DOM element
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: Then traverse the DOM to find the element that matches it, and if there is no matching element,
Returns an empty jquery object, or it will create a pair of jquery objects from these matching elements.
Copy Code code as follows:
$ (htmlstr[, Document Object])
$ ("<div> everyone Good </div>"). Append ("body"); Simple tags: no tape nodes
Three: $ (DOM Element), $ (DOM element collection) converts DOM elements into jquery objects.
The jquery constructor creates a DOM node using the original Eco-method of JS Document.createelement ()
Copy Code code as follows:
$ ("<div><a> everyone Good </a></div>"). Append ("body"); Complex tags: contains child nodes.
Four: $ (custom object) encapsulates a generic object as a jquery object.
jquery uses the document fragment Buildfragment () method to insert all child nodes into [, document objects] all at once, if not specified here, is document; $ (Html[,json object])
When HTML is a simple label, her second argument can be a JSON object that contains the properties or events of the DOM element.
Copy Code code as follows:
$ (Html[,json object])
$ ("<div></div>", {
"Class": "Gys",//Because class is the keyword of JS, so quote
Text: "Everyone is good",
Click:function () {alert ("What am I Doing");}
}). Append ("body");
The $ (callback function) binds the Ready event listener to execute when the DOM load completes.
$ (Element) or $ (elements)
Pass in a DOM object or a set of Dom objects
Copy Code code as follows:
("Div.guo"). Click (function () {
$ (this). Slideup ();
});
VI: $ (jquery object) accept a jquery object that returns a copy of a jquery object
$ (object);
Pass in a normal object
Copy Code code as follows:
var obj = {name: "Guo", age:24};
var $obj = $ (obj);
$obj. On ("Guo", function () {
Alert ("Departs from a custom event");
});
$obj. Trigger ("Guo");
Seven: $ () Create an empty jquery object.
$ (callback) pass in a function
Copy Code code as follows:
This representation executes in the function after the DOM has finished loading.
$ (jQuery Object);
Passing in a jquery object, a copy of the jquery object is created and returned, and the replica references the same DOM object as the Passed-in jquery object.