解决ie8不兼容jquery trim问题

/*为原形添加方法*/
String.prototype.trimBoth = function() {
return this.replace(/(^s*)|(s*$)/g, "");
};


String.prototype.ltrim = function() {
return this.replace(/(^s*)/g, "");
};

String.prototype.rtrim = function() {
return this.replace(/(s*$)/g, "");
};

/*添加trim方法*/
function trimBoth(str) { 
return str.replace(/(^s*)|(s*$)/g, "");
}


function ltrim(str) {
return str.replace(/(^s*)/g, "");
}


function rtrim(str) { 
return str.replace(/(s*$)/g, "");
}

原文地址:https://www.cnblogs.com/hackerxiaoyon/p/4747759.html