Document object:
Method name |
Method description |
Write (HTML) |
Inserts the specified HTML string into the document |
CreateElement (NodeName) |
Create a node of an element |
createTextNode (text) |
Create a text node |
Problem: Because it violates the JS separation principle, even if the external call JS but internal to the specified location to dynamically generate HTML, you must also add <script type= "Text/javascript" ></script> in the HTML document; Often leads to illegal data or formatting errors, so it is highly recommended to use
Node object:
Property name |
Property Description |
InnerHTML |
Gets or sets the HTML content of the given element |
ParentNode |
Gets or sets the parent node object of the current element, which can only be an element node |
NextSibling |
Gets the current element node following an element node object |
Method name |
Method description |
AppendChild (Child) |
Inserts the child node at the end of the node object's children node |
InsertBefore (new, NodeName) |
Inserts a new element node in front of the element node (nodeName), but at this point the node object must be the parent of the nodeName, that is, an insert done inside the parent element node, commonly parentnode represents |
This article is from the "ζ Automated operation and maintenance development Road ζ" blog, please be sure to keep this source http://xmdevops.blog.51cto.com/11144840/1858128
Website frontend _javascript-dom programming. 0003.JavaScriptDom Dynamic creation?