Skip to content

Instantly share code, notes, and snippets.

@qoomon
Created February 28, 2019 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qoomon/cea23c8b39af78233dabec7f15c53d9f to your computer and use it in GitHub Desktop.
Save qoomon/cea23c8b39af78233dabec7f15c53d9f to your computer and use it in GitHub Desktop.
JS Function to escape HTML text
function escapeHTML(text) {
let element = document.createElement('_');
element.innerText = text;
return element.innerHTML;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment