运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>Create a thead Element</h1> <table id="myTable"> <tr> <td>Cell 1</td> </tr> <tr> <td>Cell 2</td> </tr> <tr> <td>Cell 2</td> </tr> </table> <p>Click "Try it" to create a thead element.</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { const x = document.createElement("thead"); const y = document.createElement("tr"); const z = document.createElement("td"); z.innerHTML = "Header" y.appendChild(z); x.appendChild(y); document.getElementById("myTable").appendChild(x); } </script> </body> </html>