Skip to content

Instantly share code, notes, and snippets.

@zackd
Created November 30, 2011 18:20
Show Gist options
  • Save zackd/1410126 to your computer and use it in GitHub Desktop.
Save zackd/1410126 to your computer and use it in GitHub Desktop.
// YUI trim - for browsers with no native String.trim() e.g. IE < 9
// YUI trim - for browsers with no native String.trim() e.g. IE < 9
if (!String.prototype.trim) {
String.prototype.trim = function () {
try {
return this.replace(/^\s+|\s+$/g, "");
} catch(e) {
return this;
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment