I am trying to pass the string "{<A+_2OF3_MSF}"
to jQuery's HTML function. It doesn't work because of special character <
. I tried encoding/escaping an HTML tag using this escapeHtml function, but I am facing another issue after that.
var escapeHtml = function(theString) {
return theString.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
};
It appends HTML-encoded string as text, not as HTML. I saw the below Stack Overflow post, but then it suggests to decode it after encoding. If I do that I am back to square one.
Appending HTML-encoded string as HTML, not as text
I have created a fiddle: