zoukankan      html  css  js  c++  java
  • JS去除空格

    SCRIPT LANGUAGE="JavaScript">  
    <!--  
    //出处:网上搜集  
    // Trim() , Ltrim() , RTrim()  
    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>  
    <input type="text" value="   前后都是空格    " id="space">  
    <input type="button" value="去前后空格" onclick="javascript:document.getElementById('space').value=document.getElementById('space').value.Trim();document.getElementById('space').select();">  
    <input type="button" value="去前空格" onclick="javascript:document.getElementById('space').value=document.getElementById('space').value.LTrim();document.getElementById('space').select();">  
    <input type="button" value="去后空格" onclick="javascript:document.getElementById('space').value=document.getElementById('space').value.RTrim();document.getElementById('space').select();">  
    <input type="button" value="还原" onclick="javascript:document.getElementById('space').value='     前后都是空格    ';">  
    <a href="http://www.yaoasnsi.com" target="_blank">访问yaosansi.com</a>

  • 相关阅读:
    bzoj 1257: [CQOI2007]余数之和sum 数论
    codevs 1063 合并果子 STL 优先队列
    HTTP错误code大全
    URL中的特殊字符处理笔记
    单例中懒汉和饿汉的本质区别
    关于静态方法的使用方式
    111
    WebService 简单安全验证
    WebService安全解决方案—简单握手协议
    RESTEasy使用json返回的例子
  • 原文地址:https://www.cnblogs.com/mumue/p/2459493.html
Copyright © 2011-2022 走看看