Learn HTML DOM
Manipulating DOM Elements
4.1
Lesson

Updating Text Inside an Element Using textContent

We can get access to the text inside an HTML element using its textContent property.

You can see in the console, it logs the old text value. But, the text content later gets changed and is displayed in the browser with the text, “Better greetings”.