<html>
<head>
<style>
table,th
{
border:1px solid black;
}
</style>
</head>
<body>
<table id="myTable">
<tr id="myTr">
</tr>
</table>
<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>