<table id="myTable"> <tbody><tr id="myTr"> </tr> </tbody></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>