fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> <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>
运行结果