Jon Stuebe

ie8 trim support

ie8 trim support

Posted by Jon Stuebe on .
Featured

ie8 trim support

Posted by Jon Stuebe on .

Not sure how I didn't know this, but I stumbled upon the fact today that the trim function is not supported in ie8. Here's a quick fix for it:

if(typeof String.prototype.trim !== 'function') {
   String.prototype.trim = function() {
  return this.replace(/^\s+|\s+$/g, '');
   }
}
user

Jon Stuebe