Skip to content

Instantly share code, notes, and snippets.

@miqueiaspenha
Forked from jmblog/gist:3222899
Created November 6, 2021 18:27
Show Gist options
  • Save miqueiaspenha/2f42af00627bfc93902016cfc5aa9788 to your computer and use it in GitHub Desktop.
Save miqueiaspenha/2f42af00627bfc93902016cfc5aa9788 to your computer and use it in GitHub Desktop.
Simple HTML encoding/decoding using jQuery
// http://stackoverflow.com/questions/1219860/javascript-jquery-html-encoding
function htmlEncode(value){
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