textContent property is used to get or set text content.
Example 1 - set text content
Example 2 - get text content
Difference between textContent and innerText
In innerText the text which are visible in an web page are accessed. The hidden content cannot be retrieved.
While in textContent all the text including the hidden contents can be accessed.
In the below example, the "CodePlay" text is hidden using css display property.
When innerText button is clicked, only the text "tutorial" will appear.
When textContent button is clicked, the text "tutorial" and "CodePlay" will appear.