Replace .trim function with jQuery equivalent to prevent error in IE8