解决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, "");
}

posted @ 2015-08-21 14:16  xiaoyon  阅读(493)  评论(0编辑  收藏  举报