Node: textContent property - Web APIs | MDN (original) (raw)

Baseline

Widely available *

The textContent property of the Nodeinterface represents the text content of the node and its descendants.

Note: textContent and HTMLElement.innerText are easily confused, but the two properties are different in important ways.

Value

A string, or null. Its value depends on the situation:

**Warning:**Setting textContent on a node removes all of the node's children and replaces them with a single text node with the given string value.

Differences from innerText

Don't get confused by the differences between Node.textContent andHTMLElement.innerText. Although the names seem similar, there are important differences: