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

使用方法如下:

var a=$('#a').val().Trim()

 

posted @ 2015-12-23 13:50  Dylan(迪伦)  阅读(170)  评论(0编辑  收藏  举报