解决方法:replace(/ /g,"").replace(" ","")
测试:
<script> var str = "a b c"; alert(str); str = str.replace(/ /g,""); alert(str); </script>