我是靠谱客的博主 温婉舞蹈,这篇文章主要介绍js空格处理函数,现在分享给大家,希望可以做个参考。

原文:http://www.happyshow.org/content.asp?id=114

 

代码示例如下:

 1  < script language = " javascript " >
 2  String.prototype.trim = function (){
 3           return   this .replace( / (^s*)|(s*$) / g,  "" );
 4  }
 5  String.prototype.ltrim = function (){
 6           return   this .replace( / (^s*) / g, "" );
 7  }
 8  String.prototype.rtrim = function (){
 9           return   this .replace( / (s*$) / g, "" );
10  }
11 
12  function  test(){
13       var  strWithSpace  =   '    12345    ' ;
14      window.alert(strWithSpace + " _ " + strWithSpace.length);
15 
16      strWithSpace  =  strWithSpace.trim();
17      window.alert(strWithSpace + " _ " + strWithSpace.length);
18  }
19 
20  window.onload  =  test ;
21  < / script>

转载于:https://www.cnblogs.com/ungshow/archive/2008/09/02/1282008.html

最后

以上就是温婉舞蹈最近收集整理的关于js空格处理函数的全部内容,更多相关js空格处理函数内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(145)

评论列表共有 0 条评论

立即
投稿
返回
顶部