js去除左右空格函数

JS自身没有 trim这样的函数 来去除左右空格 ,必须通过自定义函数来实现这样的功能了。

代码如下:

	function trim(str){
		return str.replace(/(^\s*)|(\s*$)/g, "");
	}

Leave Your Comment

Your email will not be published or shared. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="">

*
请输入图片中的字符以验证你并非垃圾机器人. 点击图片收听验证码的语音版.
点击这里收听此验证码的语音版本