这个好像只能去掉2头的空格
String.prototype.trim=function (){return this.replace(/(^\s*)|(\s*$)/g,'');}
方法1:
String.prototype.mm = function (){return this.replace(/\s/g, '');}
方法2:
var s = "asd ddd bbb sss";
var reg = /\s/g;
var ss = s.replace(reg, "");
alert(ss);