trim() not supported by IE7 and IE8
Funny fact, trim function is not supported by IE7 and IE8. Ok, it is supported, but through jQuery trim function. So, when you have something like this: jQuery(...).attr().trim() , this trim() function stops having any relation to jQuery, as the attr() would return String type, which method would be then trim(). Since IE7 and IE8 do not support trim() method within String type, you should use instead jQuery.trim(jQuery(...).attr()) or if you don't wanna use jQuery (whyyyy?), you can simply implement the trim function youself. if(typeof String.prototype.trim !== 'function') { String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); } } http://www.blogger.com/img/blank.gif source 1 source 2