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.
- How to create long shadow of text without using text-shadow in HTML and CSS ?
- Text Animation with changing the color of the text using HTML & CSS
- JQuery | Get the text of a span element
- How to get text of specific option tag using jQuery?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.