js去除空格

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, "");
}

原文地址:https://www.cnblogs.com/chai-blogs/p/5254421.html