您的当前位置:首页正文

Javascript修改String对象增加去除空格功能(示例代码)_javascript技巧

来源:爱够旅游网

代码如下:
//#region 去除空格
String.prototype.Trim = function () {
return this.replace(/(^\s*)|(\s*$)/g, "");
}


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


String.prototype.RTrim = function () {
return this.replace(/(\s*$)/g, "");
}
//#endregion

显示全文