To extract only the plain text from an HTML element using JavaScript, the best and most reliable approach is to use .textContent.
.textContent
Here’s how you can do it: