zoukankan      html  css  js  c++  java
  • 测试去空格

    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>测试去空格</title>
    <script type="text/javascript" src="http://bj.xdf.cn/Portals/24/xdf_common/js/jquery-1.4.2.min.js"></script>
    <style type="text/css">
    </style>
    </head>
    <body>
    <script>
    String.prototype.trim = function() {
      return this.replace(/^ss*/, '').replace(/ss*$/, '');
    };
    $(function(){
    	var a = '  ',
    		b = '  b',
    		c = 'c  ',
    		d = '  d  ',
    		e;
    	console.log(a);
    	console.log(b);
    	console.log(c);
    	console.log(d);
    	console.log(e);
    	console.log(a.trim());
    	console.log(b.trim());
    	console.log(c.trim());
    	console.log(d.trim());
    	console.log(e ? e.trim() : '');
    	
    	console.log(a.length);
    	console.log(b.length);
    	console.log(c.length);
    	console.log(d.length);
    	
    	console.log(a.trim().length);
    	console.log(b.trim().length);
    	console.log(c.trim().length);
    	console.log(d.trim().length);
    });
    </script>
    </body>
    </html>

  • 相关阅读:
    mybatis-spring 集成
    maven 插件深入了解
    maven 常用插件3
    maven 插件2
    <转载> maven 详解 http://www.cnblogs.com/binyue/p/4729134.html
    linux base shell 基础语法
    浏览器运行原理
    <转载> js 闭包
    dubbo 学习资料
    HTTP
  • 原文地址:https://www.cnblogs.com/dulinan/p/12033052.html
Copyright © 2011-2022 走看看