innerText appending words weirdly

https://codepen.io/latuza/pen/vENMEpB Hi, when I use .innerHTML += it reserves everyhting inlcuding classes on other tags, and add text to it. But, when I use .innerText +=, it destroys everything and just add the text, why?
anon
CodePen
Untitled
...
3 Replies
Jochem
Jochem3mo ago
Because inner text only contains the text node content inside the element, not the html
brr
brrOP3mo ago
even if we append?
Jochem
Jochem3mo ago
appending is just a weird way of saying A = A + B, you take the value of itself, add something, then assign it back so yes, even if you're appending

Did you find this page helpful?