解决方法:

方法1:

使用jquery里面的全局函数$.trim()代替原生js方法trim():

$.trim( 你要替换的字符 );

方法2:


Function.prototype.method = function (name, func) {
    this.prototype[name] = func;
    return this;
};
if (!String.prototype.trim) { //判断下浏览器是否自带有trim()方法
    String.method('trim', function () {
        return this.replace(/^\s+|\s+$/g, '');
    });
    String.method('ltrim', function () {
        return this.replace(/^\s+/g, '');
    });
    String.method('rtrim', function () {
        return this.replace(/\s+$/g, '');
    });
}

 

使用方法2,这样就可以直接在你的js里面 原生调用 .trim()  方法了

相关文章:

  • 2022-12-23
  • 2021-10-15
  • 2021-12-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-19
  • 2021-05-10
  • 2021-05-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案