Javascript String strip_html()

Description

Javascript String strip_html()

// Strips HTML from string.
String.prototype.strip_html = function() {
  var value = "";
  try {/*from  w  w w .j  a  va 2 s . c  o m*/
    // This is a known idiom for stripping html.
    value = $('<p>' + this + '</p>').text();
    if (value == "") {
      value = this;
    }
  } catch(err) {
    value = this;
  } finally {
    value = value || "[Null]"
  }
  return value;
}



PreviousNext

Related