js去除空格(trim方法)

/**
* 去空格
*/
String.prototype.trim=function(){
	return this.replace(/(^\s*)|(\s*$)/g, "");
};
/**
 *去左空格 
 */
String.prototype.ltrim=function(){
	return this.replace(/(^\s*)/g,"");
};
/**
* 去右空格
*/
String.prototype.rtrim=function(){
	return this.replace(/(\s*$)/g,"");
};

  

posted @ 2015-06-23 13:55  Rain-Heart  阅读(2778)  评论(0编辑  收藏  举报