日期:2014-05-16  浏览次数:20332 次

常用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, ""); } ? ? ? ? ? ?// 去掉右空格