Get the text content of the first button element:
The result will be:
The textContent property sets or returns the textual content of the specified node, and all its descendants.
If you set the textContent proerty, any child nodes are removed and replaced by a single Text node containing the specified string.
Tip: Sometimes this property can be used instead of the nodeValue property, but remember that this property returns the text of all child nodes as well.
Get all the textual content of a list:
![]()
The textContent property is supported in all major browsers.
Note: Internet Explorer 8 and earlier does not support this property.
Set the text content of a node:
Return the text content of a node:
| Return Value: | A String, representing the text of the node and all its descendants |
|---|---|
| DOM Version | Core Level 3 |
Node Object
Your message has been sent to W3Schools.