zoukankan      html  css  js  c++  java
  • js添加行删除行

     function AddRow(tableID) {
                var tab = document.getElementById(tableID);
                tab.border = "1px";
                var newRow = tab.insertRow(tab.rows.length);
                var colsCount = document.getElementById(tableID).rows.item(0).cells.length;
                for (var i = 0; i < colsCount; i++) {
                    var cell = newRow.insertCell(i);
                    var id = "txt";
                    if (i == 0) {
                     
                        id += "Cw";
                    }
                    if (i == 1) {
                        id += "mdcSy";
                    }
                    if (i == 2) {

                        id += "mdcYx";
                    }
                    var mess = "<input type='input' id='" + id + "'/>";
                    cell.innerHTML = mess;
                  
                }
            }
            function DelRow(tableID) {
                var tab = document.getElementById(tableID);
                var rowIndex = tab.rows.length - 1;
                if (rowIndex < 1) {
                alert("表头无法删除!")
                }
                else {
                    tab.deleteRow(rowIndex);
                }
            }
            function DelRow(tableID) {
                var tab = document.getElementById(tableID);
                var rowIndex = tab.rows.length - 1;
                if (rowIndex < 1) {
                    alert("表头无法删除!")
                    return false;
                }
                else {
                    return true;
                }
            }

  • 相关阅读:
    优秀个人博客
    redis 3.0 集群__监控警报工具(sentinel)
    redis 3.0 集群__hashTag
    shell__常用命令__sed
    shell__常用命令__grep
    shell__常用命令__awk
    shell 常用命令集合
    redis 3.0 集群__配置文件详解(常用配置)
    redis 3.0 集群__故障测评
    tcp 建立连接的三次握手,以及关闭连接的4次挥手
  • 原文地址:https://www.cnblogs.com/umlzhang/p/1925472.html
Copyright © 2011-2022 走看看