Elementals.js

Latest Version: 3.6.4 PRODUCTION 13 April 2018

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

&lt;p&gt;Test &amp; &quot;the Best&quote;&lt;/p&gt;

Elementals String Methods

Elementals Extensions

Polyfills

These link to the Mozilla Developer Network (MDN)

Property Key

  • Object
  • Method or Variable
  • "Constant" Variable

Downloads

Advertisement