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>

  • 相关阅读:
    题解 LNOI2014 LCA
    题解 P3413 【SAC#1
    题解 P3372 【【模板】线段树 1】(珂朵莉树解法)
    题解 P2610 【[ZJOI2012]旅游】
    题解 CF911D 【Inversion Counting】
    题解 CF1037D 【Valid BFS?】
    bootstrap常用部件下载
    sql获取上月同期
    VSS配置
    SQL中的union,except,intersect用法
  • 原文地址:https://www.cnblogs.com/howie/p/3025460.html
Copyright © 2011-2022 走看看