js去空格的两种方法

去掉前后空格

str.trim();

 

 

去掉所有空格(前后以及中间)

str.replace(/\s/g,"");

posted @ 2020-07-17 10:59  风不动  阅读(7941)  评论(0)    收藏  举报