Method String.htmlSpecialChars
Summary:
Escapes key characters in the string to make it safe to insert into HTML.
- Calling Convention:
-
String.htmlSpecialChars()
- Parameters
- None
- Returns:
- The string with the greater than, less than, ampersand, single and double quotes escaped to their HTML entity equivalents.
Examples
HTML
var test = '<p>Test & "the Best"</p<';
console.log(test.htmlSpecialChars());
Output
<p>Test & "the Best"e;</p>