Skip to content

Instantly share code, notes, and snippets.

@torgeir
Created October 22, 2014 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save torgeir/c0a21fb4633141aef803 to your computer and use it in GitHub Desktop.
Save torgeir/c0a21fb4633141aef803 to your computer and use it in GitHub Desktop.
Js strip html tags.
var stripHtml = (function () {
var div = document.createElement('div');
return function (html) {
div.innerHTML = html;
return (div.innerText || div.textContent); // textContent is for firefox
};
})();
// stripHtml("<p>yes, <b>it works</b></p>") => "yes, it works"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment