标签为 去除左右两边空格 有1篇文章

javascript去除左右两边空格

记录一下,javascript去除左右两边空格的一个函数:

trim:去除两边空格 lTrim:去除左空格 rTrim: 去除右空格

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, "");
} ...[查看详细内容]


tags: javascript去除空格 javascript去除左右两边空格 javascript 去除左右两边空格