Skip to content

Instantly share code, notes, and snippets.

@jeffikus
Created February 11, 2013 09:55
Show Gist options
  • Save jeffikus/4753583 to your computer and use it in GitHub Desktop.
Save jeffikus/4753583 to your computer and use it in GitHub Desktop.
HTMLEntities JS
/**
* JS version of PHP htmlentities.
*
* @since 1.0.8
* @access public
*/
jQuery.fn.htmlentities = function( str ) {
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment