function changColor(txtname,lblname)
{
var str = document.getElementById(txtname).value;
比如字符串str的值是"a b c w w r";
}
怎样吧字符串值的空格去掉
我打算用replace方法,如:str.replace(/(^\s*)|(\s*$)/g,"");
但是没有成功,是不是正则表达式错了,谁能指点一下??
谢谢!!
...全文
915打赏收藏
删除空格的方法??
function changColor(txtname,lblname) { var str = document.getElementById(txtname).value; 比如字符串str的值是"a b c w w r"; } 怎样吧字符串值的空格去掉 我打算用replace方法,如:str.replace(/(^\s*)|(\s*$)/g,""); 但是没有成功,是不是正则表达式错了,谁能指点一下?? 谢谢!!