HTML stripping jQuery plugin

Small tag stripping jQuery plugin:

jQuery.fn.stripHTML = function() { 
  return this.each(function(){ 
    var me   = jQuery(this); 
    var html = me.html(); 
    me.html(html.replace(/<[^>]+>/g, "").replace(/<\/[^>]+>/g, ""));
  }); 
}

If the code is HTML encoded it needs to first be HTML decoded.

A usage example could look like this:

$(".article_title").decHTML().stripHTML();


Related Posts

Tags: , ,