1个回答
展开全部
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JS Table</title>
<style>
.blue {
background:blue;
color:#fff;
}
.red {
background:red;
color:#fff;
}
</style>
</head>
<body>
<table id="t">
<tr>
<th>Column One</th>
<th>Column Two</th>
<th>Column Three</th>
<th>Column Four</th>
</tr>
<tr>
<td>Data One</td>
<td>Data Two</td>
<td>Data Three</td>
<td>Data Four</td>
</tr>
<tr>
<td>Data Five</td>
<td>Data Six</td>
<td>Data Seven</td>
<td>Data Eight</td>
</tr>
</table>
<script>
var t = document.getElementById("t");
//下面是 js 控制表格行列
t.rows[1].cells[1].className= "blue";
t.rows[2].cells[3].className = "red";
</script>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询