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 PropertyThe 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 PropertyThe 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