Previously in the group has discussed with the hope of a innerhtml and appendchild who faster things, then did a test, the result is, in IE, innerhtml than appendchild faster, Firefox and Chrome,safari, AppendChild is faster than innerHTML.
The
This article mainly analyzes the use of AppendChild and insertBefore in js in detail. If you need it, you can refer to it for help.
AppendChild DefinitionAppendChild (newChild: Node): Node
Appends a node to the childNodes array for the
The deletion and insertion operations on HTML node elements need to be used in the past few days. Due to some troubles when using the insertBefore method, we can summarize appendChild, insertBefore, and insertAfter as knowledge.
AppendChild
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
This article is mainly on the use of JS AppendChild and InsertBefore in a detailed analysis of the introduction, the need for friends can come to the reference, I hope to help you. AppendChild definition appendchild (Newchild:node): node appends
How to use Dom AppendChild ()The AppendChild () method adds a new child node to the end of the node's child node list.
This method can return this new child node.
AppendChild (newchild) parameter descriptionNodes added by newchild
AppendChild
AppendChild definitionAppendChild (newchild:node): NodeAppends a node to the ChildNodes array for the node.Supported:ie 5.0+, Mozilla 1.0+, Netscape 6.0+, Safari 1.0+, Opera 7.0+Adding a node to an array of child nodes of the specified node is a bit
In the element. appendChild (newNode) method, if newNode itself is a node in the Dom, The appendChild method is no longer executed.
It is an append operation, but a move operation. For example:
script function f () {document. body. appendChild
In the element. appendChild (newNode) method, if newNode itself is a node in the Dom, The appendChild method is no longer executed.It is an append operation, but a move operation. For example: [Ctrl + A select all Note: If you need to
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
1, AppendChild and InsertBefore are the methods used to do the node, and InsertAfter is just a custom function2, InsertBefore relative to the appendchild, it is more flexible to insert a new node into the target node array in any location.3, the use
First, we can understand the two methods from the definition:
AppendChild () method: you can add a new subnode to the end of the node's subnode list. Syntax: appendChild (newchild)
InsertBefore () method: you can insert a new subnode before an
Document.createelement () is an object that is created in an object and is used in conjunction with the appendchild () or InsertBefore () method. where the AppendChild () method adds a new child node at the end of the node's child node list. The
AppendChild definitionAppendChild (newchild:node): NodeAppends a node to the ChildNodes array for the node.Supported:ie 5.0+, Mozilla 1.0+, Netscape 6.0+, Safari 1.0+, Opera 7.0+Adding a node to an array of child nodes of the specified node is a bit
1, append and delete HTML elements Creating HTML Elementsvar newele =document.createelement ("P");The created element is appended to another element:A. AppendChild (b): If B is a new element, add element B at the end of all child elements of the A
As AppendChild learned, the AppendChild () method adds a new child node to the end of the node's child nodes list.If you don't understand it deeply, you will often make some mistakes. I used to be haha.Let's take a look at the analysis.var mydiv =
Some time ago, when I did something and encountered several "missing objects" errors, I summarized the errors, which are related to the execution sequence of JavaScript, But I searched for them, javaScript does not seem to have the concept of a
Document. createElement () is an object created in the object. It must be used together with the appendChild () or insertBefore () method. The appendChild () method adds a new subnode at the end of the subnode list of the node. The insertBefore ()
AppendChild is mainly used to insert a node to the last window. onloadfunction () {varul2document. getElementById (& amp; #39; ul2 & amp; #39;); varolidocument. getElementsByTagName (& amp; #39; li & amp; #39 ;);
AppendChild is mainly used to append
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.