MIHA WANGFront End Web Development Techdegree Student 10,820 Points
InnerHTML and textContent
I already watch the tutorial, but both sides can change text, whats the really difference between this two? Thank you so much.
Kieran Barker14,976 Points
innerHTML property lets you insert HTML into an element, whereas the
textContent property only lets you insert text.
If I had a
div element and I set its
<h1>Title</h1>, then this new H1 element would be inserted into the element. But if I used
textContent, then the H1 opening and closing tags would literally just show as text and would not be rendered as an H1 element in the HTML.