js去掉字符串空格

String.prototype.trim=function() {

    return this.replace(/(^s*)|(s*$)/g,'');
}

原文地址:https://www.cnblogs.com/lianruihong/p/5336022.html