1、去除首尾空格:

 var txt = $('#Txt').val().trim();      

txt = txt.replace(/(^\s*)|(\s*$)/g, "");

2、去除所有空格:

 txt = txt.replace("//s/g", "");

 

相关文章:

  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
  • 2021-10-09
  • 2021-07-28
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-02
  • 2021-12-07
  • 2021-08-19
  • 2022-12-23
  • 2022-01-07
相关资源
相似解决方案