zoukankan      html  css  js  c++  java
  • js 清空文本框

    js清空文本框:

    TextBox 服务器,客户端都清空

     

    /// <summary>    
    /// 清空文本框    
    /// </summary>    
    /// <param name="controls"></param>    
    public void EmptyTextBox(ControlCollection controls)    
    {        
    foreach (Control c in controls)        
    {            
    if (c.Controls.Count > 0)            
    {                
    // 递归                
    this.EmptyTextBox(c.Controls);            
    }            
    else if (c is TextBox)            
    {                
    // 服务器控件                
    ((TextBox)c).Text = "";            
    }            
    else if (c is HtmlInputText)            
    {                
    // HTML 控件                
    ((HtmlInputText)c).Value = "";            
    }        
    }    
    }

    js前台清空

    点击按钮用Javascript清空页面上所有的文本框|文本域,代码如下:

    <script type="text/javascript">
    <!--
     function cls(){
       var sum=0;
       var t = document.getElementsByTagName_r("INPUT");
       for (var i=0; i <t.length;i++){  
      if (t[i].type=='text'){  
        ++sum;
        t[i].value="";//清空 
      }
       }
       var sum1=0;
       var t1 = document.getElementsByTagName_r("textarea");
       for (var i1=0; i1 <t1.length;i1++){  
      if (t1[i1].type=='textarea'){  
        ++sum1;
        t1[i1].value="";//清空 
      }
       }
       alert('页面共有TEXT:'+sum + ' 个\n' + '页面共有TextArea:' + sum1 +'个');
     }
    //-->

     

  • 相关阅读:
    powerdesigner 字段添加注释和默认值
    springboot集成enchance
    判断字段数据什么数据类型
    springboot打成jar包涉及到的linux命令
    springdatajpa添加完modle之后立即返回id
    阿里云上部署环境
    STS 启动之后, "Initializing Java Tooling" 一直卡住问题解决
    C#访问MongoDB数据
    MongoDB开发学习(1)开天辟地,经典入门
    Step by Step 設定 TFS 2012 Create Team Project 權限
  • 原文地址:https://www.cnblogs.com/lhws/p/2376403.html
Copyright © 2011-2022 走看看