Bryan Bryan - 4 years ago 352
HTML Question

Strip HTML from Text JavaScript

Is there an easy way to take a string of html in JavaScript and strip out the html?

Answer Source

If you're running in a browser, then the easiest way is just to let the browser do it for you...

function strip(html)
   var tmp = document.createElement("DIV");
   tmp.innerHTML = html;
   return tmp.textContent || tmp.innerText || "";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download