Created
May 11, 2016 04:53
-
-
Save hustcc/b80b59a95665188fff4c1066eb9d350a to your computer and use it in GitHub Desktop.
javascript 转义
This file contains 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
function htmlEntities(str) { | |
return String(str) | |
.replace(/&/g, '&') | |
.replace(/</g, '<') | |
.replace(/>/g, '>') | |
.replace(/"/g, '"'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment