js去除左右空格

 replace方法去掉字符串的空格

//去左空格;
s=s.replace(/(^\s*)/g, "");

//去右空格;
s= s.replace(/(\s*$)/g, "");

//去左右空格;
s=replace(/(^\s*)|(\s*$)/g, "");
posted @ 2014-10-28 09:57  明济安  阅读(541)  评论(0编辑  收藏  举报