DEV Community

Discussion on: How to do wiring in VanillaJS

Collapse
 
tarandeep_singh profile image
Tarandeep Singh • Edited

Thank you for sharing this! ๐Ÿ˜„ And yes there's no particular reason here to use innerText instead of textContent as both will work just fine. However, it's important to know the difference:

textContent gets the content of all elements, including and <style> elements. In contrast, innerText only shows โ€œhuman-readableโ€ elements. textContent returns every element in the node. In contrast, innerText is aware of styling and wonโ€™t return the text of โ€œhiddenโ€ elements.</p>