Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM nodeValue Property

HTML DOM nodeValue Property

Element Object Reference Element object

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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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 Reference Element object