解决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, "");
}
标签:jquery,ie8,trim,return,String,function,replace,str,prototype 来源: https://blog.51cto.com/u_15199183/2771946