Please use regular realize String.trim ()

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

 

 

Write a function, to clear a space before and after the string (compatible with all browsers)

 

  function trim1(str){
    return str.replace(/(^\s*)|(\s*$)/g,"");
  }

 

  

Guess you like

Origin www.cnblogs.com/wuqilang/p/11204675.html