Big class |
JQ Method |
Notes |
Creating elements |
var $h 1 = $ (" |
Wraps the included HTML as a jquery object and returns |
Create text |
var $h 1 = $ (" |
You can create text with any HTML code |
Creating properties |
var $h 1 = $ (" |
You can create text with any HTML code |
Inserting elements within a node |
$ ("Body"). Append ("ul") |
Append new content to the element that matches the former (inserted in the last child element) |
|
$ ("ul"). AppendTo ("Body") (destructive) |
Append elements matching the former to the latter (inserted in the last child element) |
|
$ ("Body"). Prepend ("ul") |
Append new content to the element that matches the former (inserted in the first child element) |
|
$ ("ul"). Prependto ("Body") (destructive) |
Append elements matching the former to the latter (inserted in the first child element) |
Inserting elements outside a node |
$ ("div"). Affter ("<p>lyo<p>") |
Insert new content after an element that matches the former |
|
$ ("<p>lyo<p>"). Insertaffter ("div") (destructive) |
Inserts an element that matches the former into the back of another specified element collection |
|
$ ("div"). Before ("<p>lyo<p>") |
Insert new content before matching elements to the former |
|
$ ("<p>lyo<p>"). InsertBefore ("div") (destructive) |
Inserts an element that matches the former into the front of another set of specified elements |
Delete Element |
var $p =$ ("P"). Remove () |
Removes all matching elements from the DOM and can return deleted elements |
|
var $p =$ ("P"). Emtpy () |
Delete all child nodes in the matching element collection |
Copying elements |
var $div = $ ("div"). Clone () |
Copy the matching DOM elements and select the replicas |
Replace element |
$ ("P"). ReplaceWith ("<div>lyo</div>") |
Replace all elements that match the former with the following HTML or DOM elements |
|
$ ("<div>lyo</div>"). ReplaceAll ("P") |
Replace all elements that match the latter with the preceding HTML or DOM elements |
Package element |
$ ("P"). Wrap (<span class ' wrap '/") |
Each element that matches the former is wrapped by the latter |
|
$ ("P"). Wrapinner (<span class ' wrap '/") |
Match each element of the former wrapped in the latter |
|
$ ("P"). Wrapall (<span class ' wrap '/") |
The element set that matches the former is wrapped by the latter |
Setting properties |
$ ("P"). attr ("title", "paragraph text") |
Properties can be set in bulk, two parameters are 1. Specify property name 2, specify property value |
Get Properties |
Alert ($ ("P"). attr ("title")) |
Setting only one parameter means reading the property value |
Delete Property |
$ ("P"). Removeattr ("title") |
Deletes the specified element property |
Append style |
$ ("P"). addclass ("Lyo") |
Append a new style to the element, specifying the class name, but first define the CSS class style |
Remove Style |
$ ("P"). Removeclass ("Lyo") |
To remove multiple class styles, you can separate them with a space, remove all, and not pass arguments |
Toggle Style |
$ ("P"). Toggleclass ("Lyo") |
1, as a switch class style name 2, whether to open the style (true/false/expression returns bool value), if the parameter is not set, the system will be based on whether there is an automatic toggle display hidden |
Judging style |
Alert ($ ("P"). Hasclass ("Lyo")) or Alert ($ ("P"). Is ("Lyo")) |
Determines whether the element contains the specified class style and returns a bool value |
Read and write HTML |
var s =$ ("div"). html ()//Read $ ("P"). HTML (s)//write |
1, without parameter table read the structure under the specified node 2. Contains the parameter table writes a string to the specified node, overwriting all content originally contained by the specified node |
Read and write text |
var s =$ ("div"). Text ()//Read $ ("P"). Text (s)//write |
Ditto |
Read and write form values |
$ (this). Val ("Lyo") |
1, does not contain the parameter to indicate reads the value 2, contains the parameters to write the value, the parameter can be an option value, or it can be the Value property values |
Read and write CSS styles |
$ ("P"). CSS ("Color", "red") $ ("P"). CSS ({color: "Red", FontSize: "2px"}) |
Note the symbol difference when a single style is set with multiple styles |
Absolute offset |
var o1=$ ("div"). EQ (0). Offset () |
Gets the relative offset of the upper-left corner of the relative window, returning the top and right properties |
Relative offset |
var o1=$ ("div"). EQ (0). Position () |
The offset distance of the specified element from the upper-left corner of the nearest parent element, but if the parent element's position is not defined as absolute/fixed/relative, the nearest parent anchor element of the current element should be the body |
High element width |
$ ("div"). Height (140px) $ ("div"). Width () |
1, no parameter, read high width, return px 2, has the parameter, sets the high width |
ELEMENT traversal |
var li = $ ("body"). Children () |
Gets all the child elements contained in the current element, returns a collection, can be filtered with ~.eq (), or with an array ~[1] |
|
var li = $ ("Body"). Parent () |
Gets the parent element that the current element contains |
|
var li = $ ("Body"). Next () |
Gets the next sibling element adjacent to the current element |
|
var li = $ ("Body"). Parent () |
Gets the previous sibling element adjacent to the current element
|