js去前后空格

var str = "abcd ";
str.trim();
报语法错误
解决方法如下:
str = str.replace(/^\s+|\s+$/g,"");

posted @ 2011-05-06 16:35  moxie  阅读(161)  评论(0编辑  收藏  举报