js去掉前后空格

function String.prototype.Trim() { return this.replace(/(^\s*)|(\s*$)/g, ""); }   
      function String.prototype.Ltrim() { return this.replace(/(^\s*)/g, ""); }
      function String.prototype.Rtrim() { return this.replace(/(\s*$)/g, ""); } 
原文地址:https://www.cnblogs.com/kaixinmenghuan/p/2062256.html