zoukankan      html  css  js  c++  java
  • 动态新增文本框

    <html>
       <head>
         <meta http-equiv="Content-Type" content="text/html; charset=GB2312">
         <script>
           var count = 0;
          
           function addByScript() {
             var table = document.getElementById("tbl1");
             var newRow = table.insertRow(table.rows.length);
             newRow.id = "row" + count;
            
             var contentCell = newRow.insertCell(-1);
             contentCell.innerHTML = '<input type="text" />';
             contentCell = newRow.insertCell(-1);
            
             var delBtn = document.createElement("input");
             delBtn.type = "button";
             delBtn.className = "button";
             delBtn.id = "btnDel"+count;
             delBtn.value = "删除";
             delBtn.onclick = new Function("del(this)");
             contentCell.appendChild(delBtn);
                    
             count++;
           }
          
           function del(obj) {
             var row = obj.parentNode.parentNode;
             row.parentNode.removeChild(row);
           }     
         </script>
       </head>
       <body>
         <fieldset>
     <legend>
             insertRow新增
    </legend>
           <input type="button" class="button" value="新增" onclick="addByScript()"/>
           <table id="tbl1">
           </table>
         </fieldset>
       </body>
     </html>

  • 相关阅读:
    hbase
    2013年实习
    Distinct Subsequences
    LumiSoft
    Implicit super constructor xx() is undefined for default constructor. Must define an explicit constructor
    XmlDocument.LoadXml和Load的区别
    应输入 #endregion 指令报错的排查技巧
    c#删除list中的元素
    Dragon Balls(hdu3635带权并查集)
    Java实现 蓝桥杯 算法训练 寻找数组中最大值
  • 原文地址:https://www.cnblogs.com/howie/p/3025460.html
Copyright © 2011-2022 走看看