HTML DOM Properties

Source: Internet
Author: User

InnerHTML Property

The simplest way to get the content of an element is to use the InnerHTML property.

The InnerHTML property is useful for getting or replacing the contents of an HTML element.

Instance

The following code gets the InnerHTML of the <p> element for id= "Intro":

Instance

In the example above, getElementById is a method, and InnerHTML is a property.

The InnerHTML property can be used to get or change any HTML element, including

NodeName Property

The NodeName property specifies the name of the node.

    • NodeName is read-only
    • The nodeName of the element node is the same as the label name
    • The nodeName of the attribute node is the same as the property name
    • The nodeName of a text node is always #text
    • The nodeName of the document node is always #document

Note: NodeName always contains the uppercase label name of an HTML element.

NodeValue Property

The NodeValue property specifies the value of the node.

    • The nodevalue of the element node is undefined or null
    • The nodevalue of a text node is the text itself
    • The nodevalue of the attribute node is the property value
Get the value of an element

The following example retrieves the value of the text node for the <p id= "Intro" > tag:

Instance
NodeType Property

The NodeType property returns the type of the node. NodeType is read-only.

The more important node types are:

element Type NodeType
Elements 1
Property 2
Text 3
Comments 8
Document 9

HTML DOM Properties

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.