Last day, I had a resolute and unyielding need to HTML Decode a string.
I saw many solutions but was not satisfied.
Then I found the StackOverFlow reference which is the most optimal solution I have seen till date. Just pasting it here for easy reference.
function htmlEncode(value){ return $('<div/>').text(value).html(); } function htmlDecode(value){ return $('<div/>').html(value).text(); }
Did I say jQuery? I sure did say optimal :P
Happy Coding!
Dependency: jQuery
0 comments on "HTML Encode Decode in Javascript/jQuery"
Subscribe in a Reader
Post a Comment