当前位置: 代码迷 >> JavaScript >> 惯用js方法留存
  详细解决方案

惯用js方法留存

热度:43   发布时间:2013-06-25 23:45:42.0
常用js方法留存

?

1、去空格

?

? ? ??function String.prototype.Trim() { return this.replace(/(^/s*)|(/s*$)/g, ""); } ? // 去掉左右空格

????? function String.prototype.Ltrim() { return this.replace(/(^/s*)/g, ""); } ? ? ? ? ? ?// 去掉左空格
????? function String.prototype.Rtrim() { return this.replace(/(/s*$)/g, ""); } ? ? ? ? ? ?// 去掉右空格

  相关解决方案