<!DOCTYPE html>
<html>
<head>
<style>
table {
width: 100%;
}
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<p>单击该按钮可更改 ID 为“myTd”的 td 的 headers 属性值。</p>
<table>
<tr>
<th id="name">姓名</th>
<th id="email">电邮</th>
<th id="phone">电话</th>
<th id="address">地址</th>
</tr>
<tr>
<td id="myTd" headers="name">Bill Gates</td>
<td headers="email">someone@example.com</td>
<td headers="phone">(800) 426-9400</td>
<td headers="address">1 Microsoft Way Redmond, WA 98052 USA</td>
</tr>
</table>
<br>
<button onclick="myFunction()">试一试</button>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("myTd").headers = "newValue";
document.getElementById("demo").innerHTML = "headers 属性的值已从“name”更改为“newValue”。";
}
</script>
</body>
</html>