<span style="font-size:18px;"> var str=" word ";
//消除左边的空格
alert("hello"+str);
alert( "hello"+str.replace(/^\s*/g,""));
//消除右边的空格
alert("hello"+str+"tom");
alert( "hello"+str.replace(/\s*$/g,"")+"tom");
//消除前后的空格
alert("hello"+str+"tom");
alert( "hello"+str.replace(/(^\s*)|(\s*$)/g,"")+"tom");</span>
6305

被折叠的 条评论
为什么被折叠?



