javascript解决IE8一下浏览器不支持trim属性的兼容性问题

if(!String.prototype.trim){

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

例:var str="  Hello Javascript  ";this

       str=str.trim();spa

      document.write(str);prototype

相关文章
相关标签/搜索