Created
May 29, 2015 13:42
-
-
Save mrroot5/b552cc0803289d043fa6 to your computer and use it in GitHub Desktop.
html encode y decode con jQuery
From http://stackoverflow.com/questions/1219860/html-encoding-in-javascript-jquery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function htmlEncode(value){ | |
//create a in-memory div, set it's inner text(which jQuery automatically encodes) | |
//then grab the encoded contents back out. The div never exists on the page. | |
return $('<div/>').text(value).html(); | |
} | |
function htmlDecode(value){ | |
return $('<div/>').html(value).text(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment