About jquery and Dom node action methods and property records _jquery

Source: Internet
Author: User
Tags wrapper

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.