javascript去掉字符串里的所有空格

去掉左右空格

String.prototype.trim=function (){return this.replace(/(^\s*)|(\s*$)/g,'');}

去掉全部空格:String.prototype.mm = function (){return this.replace(/\s/g, '');}

posted @ 2010-03-12 17:27  tohen  阅读(312)  评论(0编辑  收藏  举报