Using innerText property: We can use innerText property to get the text from HTML element.
Using textContent property: We can also use textContent property to get the text from HTML element.
Difference between innerText and textContent:
innerTextproperty returns only human-readable text while the
textContentproperty returns all the text including
innerTextproperty take care of styling of elements and did not return any hidden elements while
textContentproperty returns all the elements including the hidden ones.
innerTextproperty is defined only for HTMLElement objects, whereas
textContentproperty is defined for all Node objects.
Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML course.