Skip to content

Instantly share code, notes, and snippets.

@Alex-xd
Created January 6, 2017 15:51
Show Gist options
  • Save Alex-xd/346c1bdaa3b96c71c16311a4c8140ac3 to your computer and use it in GitHub Desktop.
Save Alex-xd/346c1bdaa3b96c71c16311a4c8140ac3 to your computer and use it in GitHub Desktop.
转义HTML
function escapeHTML(a) {
a = "" + a;
return a.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment