<html>
<head>
  <title>添加新的行</title>
</head>
<body>
  <div onclick="addTr()">添加</div>
  <table >
      <td>姓名</td>
      <td>性别</td>
      <td>操作</td>
    </tr>
  </table>
</body>
</html>

<script>
  /**
   * 添加一行
  */
 function addTr(){
  var tab = document.getElementById("myTable");
  var rowNum = tab.rows.length;

  var myInput=document.getElementById("myInput").value;
  myInput=parseInt(myInput)+1;
  document.getElementById("myInput").value=myInput;

  var newTr = tab.insertRow();//生成一个新的行
  newTr.);
    var parNode = obj.parentNode.parentNode.rowIndex;
    tab.deleteRow(parNode);//删除一行
  }
</script>

相关文章:

  • 2021-10-07
  • 2021-11-30
  • 2021-08-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-05-21
  • 2021-10-03
  • 2021-12-05
  • 2021-05-13
  • 2021-04-03
相关资源
相似解决方案