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: , ,

Posts linking to this article:

[Web] 連結分享
PHP. Generate HTML drop downs from arrays & ranges with a PHP class; Major glob() fail; TOP PHP frameworks in terms of number of books published on a given framework; CSS Variables with PHP; PHP Frameworks : First glimpse for beginners ...

Subscribe with Google Reader