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);
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);
相关文章推荐
- 一个页面显示多个倒计时
- js实现iframe框架取值的方法(兼容IE,firefox,chrome等)
- 文本框只能输入0-100的数字
- JS版获取最长公共子串的方法
- JS获取浏览器及屏幕高度和宽度等信息
- javascript需要知道的1
- 学习JavaScript设计模式(单例模式)
- javascript bom是什么及bom和dom的区别
- 画扑克牌的 JS 库
- javascript日常使用
- Javascript模仿淘宝信用评价实例(附源码)
- JSON介绍
- Javascript BOM学习小结(六)
- js 扩展Array支持remove方法
- js替换链接和文字
- js实现延时加载Flash的方法
- 学习JavaScript设计模式(链式调用)
- JS的作用域和作用域链
- javascript 如何获取return回来的对象值
- JavaScript中的ForIn遍历