Learn HTML DOM
Manipulating DOM Elements
4.3
Lesson

Difference Between textContent and innerText

The innerText property returns the visible text inside the element whereas textContent returns the complete text, whether hideen from view or not.

Look at the console result, and you’ll see that the innerText property only returned “Battle” because the other text had the css property display set to none. Whereas, the textContent property returned the complete text, “Battle of the sharpest minds” regardless whether the text was visible or not.