Difference between innerText and textContent.

Faisal Ahmed - Jan 28 '22 - - Dev Community

innerText returns the visible text contained in a node only, where textContent returns the full text.


<span>Hello <span style="display: none;">World</span></span>

Enter fullscreen mode Exit fullscreen mode
  • innerText will return 'Hello'

  • textContent will return 'Hello World'

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .