运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <html> <body> <p>Click the button to create a HEADER element containing a h3 element with some text.</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var x = document.createElement("HEADER"); x.setAttribute("id", "myHeader"); document.body.appendChild(x); var y = document.createElement("H3"); var t = document.createTextNode("This is a h3 element in a header element"); y.appendChild(t); document.getElementById("myHeader").appendChild(y); } </script> </body> </html>