Search w3schools.com:

SHARE THIS PAGE

DOM Node nodeValue Property

Node Object Reference Node Object

Example

Get the node value of the first button element:

document.getElementsByTagName("BUTTON")[0].childNodes[0].nodeValue;

The result will be:

Try it yourself

Try it yourself »

Definition and Usage

The nodeValue property sets or returns the node value of the specified node.

Note: If you want to return the text of an element, remember that text is always inside a Text node, and you will have to return the Text node's node value (element.childNodes[0].nodeValue).

Tip: An alternative to the nodeValue property can be the textContent property.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The nodeValue property is supported in all major browsers.


Syntax

Set the node value:

node.nodeValue=value

Return the node value:

node.nodeValue

Technical Details

Return Value: A String, representing the value of the node
DOM Version Core Level 1


Node Object Reference Node Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]