A list of the operations node methods for jquery was found online. As follows:
Method |
Source Wrapper Set/String |
Target Packaging Group |
Attribute description |
A.append (B) |
B |
A |
If the destination wrapper set matches only one element, then the source (which also includes all elements that match the homologous wrapper set) is moved to the target location; If the destination wrapper set contains more than one element, the source remains in its original location, but copies an identical copy to the target location. Thus, if the target matches only one element, the source will be deleted when the preceding method is used. |
B.appendto (A) |
A.prepend (B) |
B.prependto (A) |
A.before (B) |
B.insertbefore (A) |
A.after (B) |
B.insertafter (A) |
For example: In the table above, A.append (b) means to add B to the existing content of all elements that match a, so B is the source, and a is the destination wrapper set.
The bottom line is this: After using the above method, two nodes become sibling siblings
The following is a summary of the methods of the DOM operations node:
(1) AppendChild method for adding a node to the end of the ChildNodes list
Add NewNode to the end of the Somenode childnodes list
var returnednode = Somenode.appendchild (NewNode);
Change the first child node of Somenode to the last child node
var returnednode = Somenode.appendchild (somenode.firstchild);
(2) InsertBefore method, you can put the node in the ChildNodes list in a specific position
Become the last child node after inserting
Returnednode = Somenode.insertbefore (NewNode, NULL);//Same as AppendChild effect
Become the first child node after inserting
Returnednode = Somenode.insertbefor (NewNode, somenode.firstchild);
(3) The ReplaceChild method replaces child nodes and accepts two parameters: the child node to insert and the child node to replace. The child node to be replaced will be removed from the document tree, and the child node to be inserted occupies its place
Replace the first child node
Returnednode = Somenode.replacechild (NewNode, somenode.firstchild);
(4) RemoveChild method for removing child nodes
Remove first child node
var formerfirstchild = Somenode.removechild (somenode.firstchild);
The sum of the words is: The above methods are the parent node operation child node
The following figure gives a lookup relationship between parent-child and sibling nodes
The above about jquery and Dom node operation methods and property records are small series to share all the content, hope to give you a reference, but also hope that we support the cloud habitat community.