Skip to content

Instantly share code, notes, and snippets.

@greggnakamura
Created February 1, 2016 18:16
Show Gist options
  • Save greggnakamura/945b1a68bdadae3c6124 to your computer and use it in GitHub Desktop.
Save greggnakamura/945b1a68bdadae3c6124 to your computer and use it in GitHub Desktop.
Javascript / jQuery: Snippets
// strip html tags from string
// https://css-tricks.com/snippets/javascript/strip-html-tags-in-javascript/
(function ($) {
var strippedString, items = $('.selector');
$.each(items, function (value) {
var currentText = $(this).text();
strippedString = currentText.replace(/(<([^>]+)>)/ig,"");
$(this).html(strippedString);
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment