Website frontend _javascript-dom programming. 0003.JavaScriptDom Dynamic creation?

Source: Internet
Author: User

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?

Related Article

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.