去两边空格 function myTrim(x) { return x.replace(/^\s+|\s+$/gm, ''); } //去两边空格 var str = myTrim(" Hello World! "); alert(str); 相关文章: 2021-10-04 2021-10-29