I'm trying to decode some specail characters in my string, before input it in HTML. But, for some reason, it didn't work. For ex:
My input string is "ampere 13th\'."
In JS I'm replacing every special character with this function:
htmlEntities: function(str) {
return str.replace(/\\/g, "\").replace("'", "'").replace(".", ".").replace("%", "%").replace("\"",""");
},
But, when put it to HTML, it still looks like : "ampere 13th\'."
I want to show my data with replaced special characters.
What I'm doing wrong?