Dom Node Method

Source: Internet
Author: User
OBJ. appendchild (newe)Add the child node to the end of the parent node.
OBJ: parent element reference of the node to be added; newe: new node to be added.
Note: I found that when adding a subnode, the parent node cannot be referenced. If the parent node is referenced, the browser will crash due to overflow (as if using this word.

OBJ. clonenode (boolen)Get a copy of the current node
OBJ: reference of the current node; boolen: Boolean value, true: including the child nodes of the current node; false: not included. The returned value is a reference to the current node.

OBJ. haschildnodes ()Check whether a subnode exists at the current node. The returned value is a Boolean value. True indicates yes, and false indicates no.
OBJ: the node to be checked. In fact, the childnodes. Length attribute can also be used for detection, but the returned value of this attribute is the number of nodes.

OBJ. parentnode. insertbefore (newe. OBJ)Insert a new node before the current node.
OBJ: reference of the current node. ocument. getelementbyid ("tdiv"). childnodes (2) provides a byte point location variable, which can be placed anywhere.
Parentnode: Reference to the parent node of the current node, because this method inserts a new node before the current node, which is equal to inserting a byte point under the parent node, therefore, to reference the parent node, we do not need to know the information of its parent node, but only need to use the parentnode attribute.
Newe: The new node to be inserted.

OBJ. parentnode. removechild (OBJ)Delete a subnode
OBJ. parentnode: references to the parent node of the child node to be deleted. The principle is similar to that of "obj. parentnode. insertbefore (newe. OBJ.
OBJ: The subnode to be deleted.

OBJ. parentnode. replaceChild (newe, OBJ)Replace Old nodes with new nodes
OBJ. parentnode: refers to the parent node of the child node to be replaced. The principle is the same as above.
Newe: used to replace the New node of the old node.
OBJ: The old node to be replaced.

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.