x
 
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
}
</style>
</head>
<body>
<h3>如何访问 CAPTION 元素的演示</h3>
<table>
  <caption id="myCaption">每月存款</caption>
  <tr>
  <th>月份</th>
  <th>存款</th>
  </tr>
  <tr>
  <td>一月</td>
  <td>$100</td>
  </tr>
  <tr>
  <td>二月</td>
  <td>$180</td>
  </tr>
</table>
<p>单击按钮将标题的颜色设置为红色。</p>
<button onclick="myFunction()">试一试</button>
<script>
function myFunction() {
  var x = document.getElementById("myCaption");
  x.style.color = "red";
}
</script>
</body>
</html>