offline version v3


183 of 264 menu

nodeValue property

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

Syntax

node.nodeValue;

Example

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

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

The code execution result:

'text'

See also

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