Skip to content

Instantly share code, notes, and snippets.

@jgarciaruiz
Last active February 10, 2016 10:55
Show Gist options
  • Save jgarciaruiz/6d91aba3e574e361d01b to your computer and use it in GitHub Desktop.
Save jgarciaruiz/6d91aba3e574e361d01b to your computer and use it in GitHub Desktop.
Remove leading and trailing white spaces from html string. [Polyfill]
//// http://stackoverflow.com/questions/10032024/how-to-remove-leading-and-trailing-white-spaces-from-a-given-html-string
//Running the following code before any other code will create trim() if it's not natively available.
if(!String.prototype.trim) {
String.prototype.trim = function () {
return this.replace(/^\s+|\s+$/g,'');
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment