x
 
<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
}
</style>
</head>
<body>
<table id="myTable">
 <tbody>
   <tr>
     <td>Cell 1</td>
   </tr>
   <tr>
     <td>Cell 2</td>
   </tr>
  </tbody>
</table>
<p>单击该按钮创建一个 THEAD 元素(以及一个 TR 和一个 TD)。</p>
<button onclick="myFunction()">试一试</button>
<script>
function myFunction() {
  var x = document.createElement("THEAD");
  var y = document.createElement("TR");
  var z = document.createElement("TD");
  z.innerHTML = "Header"
  y.appendChild(z);
  x.appendChild(y);
  document.getElementById("myTable").appendChild(x);
}
</script>
</body>
</html>