var x = document.getElementById('test');
Here’s how we can use innerText and innerHTML on this variable.
After click innerHTML:
After click innerText:
As we can see from the example above the innerText property sets or returns the text content as plain text of the specified node, and all its descendants whereas the innerHTML property gets and sets the plain text or HTML contents in the elements. Unlike innerText, inner HTML lets you work with HTML rich text and doesn’t automatically encode and decode text.
- HTML | DOM innerText Property
- How to add innerHTML to print page?
- HTML | DOM innerHTML Property
- How to replace innerHTML of a div using jQuery?
- What is the difference between (NaN != NaN) & (NaN !== NaN)?
- Difference between ASP and ASP.NET
- Difference between JSP and ASP
- Difference between “!==” and “==!” in PHP
- What is the difference between GUI and CUI?
- Web 1.0, Web 2.0 and Web 3.0 with their difference
- What is the difference between CSS and SCSS ?
- Difference between "." and "#" selector in CSS
- Difference Between HTML and ASP
- What is the difference between the | and || or operator in php?
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.