Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

escapeHTML(subjectString) ⇒ String

Converts the characters &, <, >, " and ' in a string to their corresponding HTML entities.

Returns: String - Returns the escaped string.
Throws:

  • TypeError If subjectString is not string.
Param Type Description
subjectString String The HTML string to escape.

Example

escapeHTML('<script src="main.js"></script>');
// => '&lt;script src=&quot;main.js&quot;&gt;&lt;/script&gt;'

escapeHTML('Hello & <span>World</span>');
// => 'Hello &amp; &lt;span&gt;World&lt;/span&gt;'

escapeHTML('<p data-id="1">lorem ipsum</p>');
// => '&lt;p data-id=&quot;1&quot;&gt;lorem ipsum&lt;/p&gt;'