js替换所有空格

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

如果直接使用replace(" ","")则只能替换一个空格

posted @ 2020-05-14 19:23  zhaogaojian  阅读(2386)  评论(0编辑  收藏  举报