ie8 不支持 trim方法 那就自己写一个trim() String.prototype.trim = function() { return this.replace(/(^s*)|(s*$)/g, ""); //正则匹配空格 }