Skip to content

Instantly share code, notes, and snippets.

@artembeloglazov
Created May 5, 2016 10:59
Show Gist options
  • Save artembeloglazov/1862546139c62ce047aa1877e6924c13 to your computer and use it in GitHub Desktop.
Save artembeloglazov/1862546139c62ce047aa1877e6924c13 to your computer and use it in GitHub Desktop.
// htmlentities_encoding на javascript'e
$('<div/>')
.text(html_string)
.text()
.replace(/&/g, '&amp;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment