//重写trim方法 if(!String.prototype.trim){ String.prototype.trim = function(){ return this.replace(/^s+/,"").replace(/s+$/,""); } } //写fntrim去掉左右空格 function fntrim(str){ return str.replace(/^s+/,"").replace(/s+$/,""); }