innerText vs. textContent

Continuing the discussion from I Made A Chat Website:

I personally like using innerText, what’s the difference (if any) between textContent and innerText?

2 Likes

innerText gets the content of all elements whose display attribute is not set to hidden.

While textContext gets the content of all elements, including special elements like <script> and <style>.

4 Likes

(Just a by-the-way, I believe you meant display attribute set to none.)

1 Like