//1:准备数据
var dates = [
{
name:'千机',
subject:'语文',
score:100
},
{
name:'祁珞',
subject:'语文',
score:100
},
{
name:'思婵',
subject:'数学',
score:0
}
];
1:准备数据。 数组里可以存放很多东西,所以可以把创建的对象放进数组
<table>
<thead>
<th>姓名</th>
<th>科目</th>
<th>成绩</th>
<th>操作</th>
</thead>
<tbody></tbody>
</table>
2:HTML代码 因为是动态生成表格,所以tbody里没有内容
<style>
table{
width: 500px;
height: 100px auto;
}
td,th{
border: 1px solid #333;
}
thead tr{
height: 40px;
background-color: #ccc;
}
</style>
3:CSS样式