x
 
<!DOCTYPE html>
<html>
<head>
<style>
table,th
{
border:1px solid black;
}
</style>
</head>
<body>
<table id="myTable">
  <tr id="myTr">
  </tr>
</table>
<h3>演示如何创建 TH 元素</h3>
<p>点击按钮来创建 TH 元素。</p>
<button onclick="myFunction()">亲自试一试</button>
<script>
function myFunction()
{
var x = document.createElement("TH");
var t = document.createTextNode("新的表头");
x.appendChild(t);
document.getElementById("myTr").appendChild(x);
}
</script>
</body>
</html>