<style>
table {
width: 500px;
margin: 100px auto;
text-align: center;
/* 使边框的重叠部分不重叠 */
border-collapse: collapse;
}
th,
td {
border: 1px solid #333;
}
</style>
</head>
<body>
<!-- cellspacing='0' 使单元格之间的距离为0 -->
<table cellspacing='0'>
<thead>
<tr>
<th>姓名</th>
<th>科目</th>
<th>成绩</th>
<th>操作</th>
</tr>
</thead>
<tbody>
</tbody>
<script>
// 1. 先准备好学生的数据,利用数组的形式放在一起 (创建对象)
var datas = [{
name: '魏璎珞',
object: 'JavaScript',
score: 100,
动态生成表格案例
最新推荐文章于 2022-03-16 11:08:14 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)