同志门!在js中如何去掉字符串中的所有空格啊!

解决方案 »

  1.   

    javascript:alert(("test test tesatste set setsa  as").replace(/ /g,'')); void(0);
      

  2.   

    <script>
    str="test test tesatste set setsa  as"
    str=str.replace(/\s*/g,"")
    alert(str)
    </script>
      

  3.   

    <script>
    str="test test tesatste set       setsa  as"
    str=str.replace(/[\s ]/g,"")
    alert(str)
    </script>
    还应该把全角空格考虑在内
      

  4.   

    zhaoxiaoyang(梅雪香@深圳) 高见!