Converts the characters &, <, >, " and ' in a string to their corresponding HTML entities.
Returns: String - Returns the escaped string.
Throws:
TypeErrorIfsubjectStringis not string.
| Param | Type | Description |
|---|---|---|
| subjectString | String |
The HTML string to escape. |
Example
escapeHTML('<script src="main.js"></script>');
// => '<script src="main.js"></script>'
escapeHTML('Hello & <span>World</span>');
// => 'Hello & <span>World</span>'
escapeHTML('<p data-id="1">lorem ipsum</p>');
// => '<p data-id="1">lorem ipsum</p>'