nodeValue property

The nodeValue property allows you to find out the value of a node or set it in HTML code.

Syntax

javascriptnode.nodeValue;

Example

Let's display the text of an element using the nodeValue property:

html<p id="elem">text</p>
javascriptlet elem = document.querySelector('#elem');
let value = elem.nodeValue; 
console.log(value);

The code execution result:

javascript'text'

See also

  • the textContent property
    that contains an element text
  • the innerHTML property
    that contains an HTML code of an element