﻿

$.fn.setHtml = function(html) {
    return $(this).html(htmlDecode(html));
};

function htmlDecode(html) {
    if (isHtml(html)) {
        return html.replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(/&gt;/g, '>');
    }
    else {
        return html;
    }
}

function isHtml(str) {
    var str = typeof (str) === "string" ? str.toString() : "";
    if (str.search(/&amp;/g) != -1 || str.search(/&lt;/g) != -1 || str.search(/&gt;/g) != -1)
        return true;
    else
        return false;
}