根据数据创建table案例
来源:互联网 发布:kali linux和centos 编辑:程序博客网 时间:2024/06/05 17:06
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Document</title><script src="jquery-1.12.4.min.js"></script></head><body><script>var data = [{name:'张三',age:19,gender:'男'},{name:'李四',age:19,gender:'男'},{name:'张三',age:19,gender:'男'},{name:'王五',age:12,gender:'男'},{name:'张三',age:15,gender:'女'},{name:'张三二',age:19,gender:'男'},{name:'张三',age:19,gender:'女'}];var table = document.createElement('table');table.boredr = 1;table.style.border = '1px solid blue';var tbody = document.createElement('tbody');table.appendChild(tbody);$.each(data,function(i,v){//遍历每一个{}对象var tr = document.createElement('tr');var num = document.createElement('td');num.style.border = '1px solid blue';num.style.width = '100px';num.style.height = '20px';num.appendChild(document.createTextNode(i));tr.appendChild(num);$.each(v,function(index,value){//遍历{}中的每一项var td = document.createElement('td');td.style.border = '1px solid blue';td.style.width = '100px';td.style.height = '20px';td.appendChild(document.createTextNode(value));tr.appendChild(td);})tbody.appendChild(tr);})document.body.appendChild(table);//真的使用jq来生成代码$('<table border="1"><tbody>'+$.map(data,function(v,i){ return '<tr><td style="width=100px;heigth=20x;">'+i+'</td>'+$.map(v,function(value){ return '<td style="width:100px;heigth:20px;">'+value+'</td>'; }).join('')+'</tr>';}).join('')+'</tbody></table>').appendTo('body');</script></body></html>
1 0
- 根据数据创建table案例
- 根据页面table某列筛选数据
- js根据条件过滤table数据
- 根据JSON数据,自动生成Table
- 根据JSON数据,自动生成Table
- Js根据table的id导出table中的数据…
- mybatis generator 根据table 创建mapping、dao、model
- 1.2 案例:利用构造函数创建表格 table
- jsp页面根据json数据动态生成table
- jsp页面根据json数据动态生成table
- jsp页面根据json数据动态生成table
- Cxgrid根据数据集动态创建列
- 根据Excel文件创建数据集
- Hbase创建表插入查询数据案例
- 根据table导出Excel
- 创建Table
- 创建table
- 创建案例
- 文章标题 UVALive 4670 : Dominating Patterns (AC自动机模板题)
- matlab r2012b 安装
- 使用google注册教程
- 书写数字的识别
- wpf之旅
- 根据数据创建table案例
- 【Codeforces 767 A. Snacktower】
- Windows下Anaconda的安装和简单使用
- 安卓开源项目周报0215
- Sping Security 4 Role Based Login Example(4)
- 深入HashCode方法
- 彻底解决:Incorrect string value: '\xF0\x9F\x98\xAD",...' for column 'commentContent' at row 1
- oj1943: C语言实验——Hello World!(printf练习)
- Spring MVC 文件上传与下载