HTML DOM outerText Property
Example
Set the outer text of an element:
document.getElementById("myH1").outerText = "Changed content!";
Try it Yourself »
Description
The outerText property sets or returns the text content of the specified node.
This property is similar to the inner innerText property, in fact getting the outerText returns the same result as getting the innerText property.
There are an important difference when setting an element's outerText, because the element itself is removed.
Tip: also check out the outerHTML property.
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
outerText | 43 | 11 | Not supported | 6 | 61 |
Syntax
Return the text content of a node:
node.outerText
Set the text content of a node (replacing the entire node):
node.outerText = text
Property Values
Value | Type | Description |
---|---|---|
text | String | Specifies the text content to insert |
Technical Details
Return Value: | A String, representing the text content of a node and all its descendants |
---|