Skip to content

Instantly share code, notes, and snippets.

@dbushell
Created May 1, 2012 10:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dbushell/2567294 to your computer and use it in GitHub Desktop.
Save dbushell/2567294 to your computer and use it in GitHub Desktop.
HTML Entities with jQuery and the Browser
var div = $('<div/>');
function encodeEntities(str) {
return div.text(str).html();
}
function decodeEntities(str) {
return div.html(str).text();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment