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.