jQuery.htmlspecialchars()
Categories: Utilities
jQuery.htmlspecialchars( text, [ quotType ] )Returns: String
Plugin: jQuery.string
Description: Escape special html chars.
-
jQuery.htmlspecialchars( text, [ quotType ] )
version added: 1.0text A HTML or XML formated string.
quotType An indication which quot types will be escaped, (0=double quotes, 1=single quotes, 2=both).
The jQuery.htmlspecialchars()
method escapes special chars like ''<'', ''>'', ''&'' and quotes from a HTML and XML string.
-
Escape special chars.
Code:
jQuery.htmlspecialchars("<div>Header<span class="subheader">My Subtitle.</span>And the end.</div>");
Results:
<div>Header<span class="subheader">My Subtitle.</span>And the end.</div>