outerText property of the
HTMLElement interface returns the same value as
HTMLElement.innerText. When used as a setter it replaces the whole current node with the given text (this differs from
innerText, which replaces the content inside the current node).
HTMLElement.innerText for more information and examples showing how both properties are used as getters.
A string representing the rendered text content of an element and its descendants.
If the element itself is not being rendered (for example, is detached from the document or is hidden from view), the returned value is the same as the
When used as a setter it replaces the current node with the given text, converting any line breaks into
This example highlights the fundamental difference between
innerText when used as setters (they are the same when used by getters).
Consider a page that contains the following HTML:
p.outerText = "Whole element replaced" replaces the whole selected
<div>Whole element replaced</div>
p.innerText = "Content inside element replaced" replaces the content inside the selected
<p>Content inside element replaced</p>