js实现Trim(),去空格

<SCRIPT LANGUAGE="JavaScript"> 
<!-- 
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, ""); 
} 
//--> 
</SCRIPT> 

 

posted @ 2012-12-07 13:02  Uoolo  阅读(459)  评论(3编辑  收藏  举报