JSJQ

您所在的位置:网站首页 jq去掉前后空格 JSJQ

JSJQ

2024-07-14 20:56| 来源: 网络整理| 查看: 265

!!! JS

一、左空格

 function Trim(str,is_global)

{

            var result;

            result = str.replace(/(^\s+)|(\s+$)/g,"");

            if(is_global.toLowerCase()=="g")

            {

                result = result.replace(/\s/g,"");

             }

            return result;

}

 

二、

去除所有空格: str = str.replace(/\s+/g,""); 去除两头空格: str = str.replace(/^\s+|\s+$/g,""); 去除空格(TimeSheet用过) arg0=arg0.replace(/\s+$|^\s+/g,""); 去除左空格: str=str.replace( /^\s*/, ''); 去除右空格: str=str.replace(/(\s*$)/g, "");三、左边空格

  function trim(str){     return str.replace(/^(\s|\xA0)+|(\s|\xA0)+$/g, '');   }

!!!-JQ

   function Trim(str)

         { 

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

     }



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3