js去掉字符串的空格

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

posted @ 2012-05-07 14:04  狼里格朗  阅读(150)  评论(0编辑  收藏  举报