DEV Community

Cover image for Difference between innerText and textContent.
Faisal Ahmed
Faisal Ahmed

Posted on

Difference between innerText and textContent.

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'

Top comments (0)