Created
April 20, 2013 05:22
-
-
Save varemenos/5424852 to your computer and use it in GitHub Desktop.
JavaScript - Escape HTML special characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// source: http://stackoverflow.com/a/9251169/649239 | |
var escape = document.createElement('textarea'); | |
function escapeHTML(html) { | |
escape.innerHTML = html; | |
return escape.innerHTML; | |
} | |
function unescapeHTML(html) { | |
escape.innerHTML = html; | |
return escape.value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment