当前位置:   article > 正文

js动态创建Html表格

js动态创建Html表格

js动态创建Html表格

function createTable(rowNum,cellNum) {
        var newtable = document.getElementById("newtable");
        for (var i = 0; i < rowNum; i++) {
            var rows = newtable.insertRow(i);
            for (var k = 0; k < cellNum; k++) {
                var cells = rows.insertCell(k);
                cells.style.textAlign="center";
                cells.style.border="#d2d2d2 solid 1px";
                cells.style.backgroundColor="white";
                cells.style.width="172px";
                cells.style.height="47px";
                cells.id = "cell"+i+k;
                var ipt = document.createElement("input");
                ipt.setAttribute("type","text");
                ipt.style.width="172px";
                ipt.style.height="47px";
                ipt.style.textAlign="center";
                ipt.style.border="#d2d2d2 solid 1px";
                ipt.placeholder = "可手动输入";
                ipt.id="inputIdx"+i+k;
                cells.appendChild(ipt);
            }
        }
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号