Skip to content

Instantly share code, notes, and snippets.

@minhd
Created September 3, 2012 05:08
Show Gist options
  • Save minhd/3606841 to your computer and use it in GitHub Desktop.
Save minhd/3606841 to your computer and use it in GitHub Desktop.
javascript htmlentities
function htmlEntities(str) {
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment