HTML DOM nodeValue Property
Example
Get the node value of the first button element:
document.getElementsByTagName("BUTTON")[0].childNodes[0].nodeValue;
Output result:
Try it
Try it »
Definition and Usage
The nodeValue property sets or returns the value of the node based on the node type.
Note: If you want to return the text of an element, remember that the text is usually inserted into a text node, so what is returned is the node value of the text node (element.childNodes[0].nodeValue).
Tip: another property for getting the node value the textContent property.
Browser support





All major browsers support the nodeValue property
Syntax
Set the node value:
node
.nodeValue=
value
Return the node value:
node
.nodeValue
Technical Details
| Return Value: | A string of the node value. |
|---|---|
| DOM version | Core Level 1 Node Object |
Element object