Sometimes, we want to get the pure text without HTML element using JavaScript.
In this article, we’ll look at how to get the pure text without HTML element using JavaScript.
How to get the pure text without HTML element using JavaScript?
To get the pure text without HTML element using JavaScript, we use the innerText
property.
For instance, we write
const element = document.getElementById("txt");
const text = element.innerText;
element.innerHTML = text;
to select the element with getElementById
.
Then we get the plain text from the element with the innerText
property.
Conclusion
To get the pure text without HTML element using JavaScript, we use the innerText
property.