js 动态创建table并且为table 添加行列

来源:互联网 发布:永恒之塔男性捏脸数据 编辑:程序博客网 时间:2024/05/22 09:43
    var div = document.getElementById("pan_table_div");
    div.innerHTML ="";
     var table = document.createElement("table");//创建table
    table.setAttribute("id","modelTable");
    table.setAttribute("class","modelTable pan_single_table");

    table.setAttribute("style","width:100%");

         //动态创建行,列
        var row = table.insertRow();
        row.setAttribute("style","background-color: #F2F7FD");
        var cell = row.insertCell();//创建一个单元
        cell.setAttribute("class","td_align_center");
        cell.innerHTML = "编码";
        cell = row.insertCell();//创建一个单元
        cell.setAttribute("class","td_align_center");
        cell.innerHTML = "名称";

       div.appendChild(table);

0 0
原创粉丝点击