Nodejs HTML Decode htmlDecode(value)

Here you can find the source of htmlDecode(value)

Method Source Code

function htmlDecode(value)
{
    if(value)//from  ww w  .jav  a  2 s  .com
    {
        return $("<div />").html(value).text();
    }
    else
    {
        return '';
    }
}

Related

  1. htmlDecode()
    String.prototype.htmlDecode = function() {
      return this.replace(/\&amp\;/g, '\&').replace(/\&gt\;/g, '\>').replace(
          /\&lt\;/g, '\<').replace(/\&quot\;/g, '\'').replace(/\&\#39\;/g,
          '\'');
    };
    
  2. htmlDecode()
    String.prototype.htmlDecode = function () {
        var div = document.createElement('div');
        div.innerHTML = this;
        return div.innerText || div.textContent;
    };
    
  3. decodeHtml()
    String.prototype.decodeHtml = function () {
        var string = new String(this);
        string = string.replace(/&lt;/g, "<");
        string = string.replace(/&gt;/g, ">");
        string = string.replace(/&quot;/g,  "\"")
        string = string.replace(/&39;/g,  "'");
        string = string.replace(/&amp;/g, "&");
        return string
    
  4. decodeHtmlEntity()
    String.prototype.decodeHtmlEntity = function(){
        var ta = document.createElement('textarea');
        ta.innerHTML = this;
        return ta.value;
    };