Skip to content

Instantly share code, notes, and snippets.

@faridv
Created August 8, 2017 06:51
Show Gist options
  • Save faridv/3cdb5094f1336c9ba0223ab4811fc166 to your computer and use it in GitHub Desktop.
Save faridv/3cdb5094f1336c9ba0223ab4811fc166 to your computer and use it in GitHub Desktop.
Removing unwanted html tags while keeping their contents -- similar to PHP's strip_tags()
// Grabbed from here: https://stackoverflow.com/a/5601929/893111
var whitelist = 'p, img, strong';
$("*").not(self.whitelist).each(function(){
var content = $(this).contents();
$(this).replaceWith(content);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment