The two methods are understood first from the definition:appendchild () method: You can add a new child node to the end of the node's child nodes list . Syntax: AppendChild (newchild)insertbefore () method: You can insert a new child node before the
First, InsertBefore ()The following code: Find the span label and cut the span tag to the front of the Div"en"> "UTF-8"> divspan Second, InsertAfter ()Just the opposite of InsertBefore."en"> "UTF-8"> divspan Third, AppendTo ()AppendTo (), like
Detailed comparison between js AppendChild and insertBefore
This article mainly compares AppendChild and insertBefore usage in js in detail. For more information, see.
We know that both appendChild and insertBefore have the function of inserting
We know that both appendchild and insertbefore have the function of inserting nodes. However, there are some differences between the two in terms of applications.For example, when we want to insert a subnode P in the following Div: node node We
Vue Virtual Dom implements snabbdom decryption and vuesnabbdom
Vue mentioned in the official document that compared with react's rendering performance, it has better performance because it uses snabbdom.
The JavaScript overhead is directly related
We know that both appendchild and insertbefore have the function of inserting nodes. However, there are some differences between the two in terms of applications.
For example, when we want to insert a subnode P in the following Div:
node node
We know that both appendchild and InsertBefore have the ability to insert nodes. But in the application, there are some differences between the two.
For example, if we were to insert a child node p in the following div:
NodeNode
We can write it
The Document Object Model (DOM) is one of the most common tools used to manipulate xml and HTML data. However, its potential is rarely fully explored. Document Object Model (DOM) is one of the most common tools used to manipulate xml and HTML data.
Target.insertbefore (Newchild,existingchild)Parameter description:1.target: The node being added and the parent node of the existing node.2.newChild: The node that will be inserted.3.existingChild: The existing node, the new node will be inserted in
The previous article in this series examined the concepts involved in the Document Object Model (DOM) programming-How web browsers regard web pages as a tree. Now you should understand the programming structure used in Dom. In this tutorial, we will
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.