Last active
November 16, 2015 18:38
-
-
Save danbrianwhite/bec32f20d5eac7c4e5fa to your computer and use it in GitHub Desktop.
Enocde a JS string to be used in an HTML element's attritube
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
String.prototype.encodeTag = function () { | |
return this.replace(/&/g, '&').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