您的位置:首页 > Web前端 > JavaScript

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

2015-11-26 15:30 513 查看
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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: