W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <p>单击该按钮可创建包含 H4 和 P 元素的 ASIDE 元素。</p> <button onclick="myFunction()">试一试</button> <script> function myFunction() { var x = document.createElement("ASIDE"); x.setAttribute("id", "myAside"); document.body.appendChild(x); var heading = document.createElement("H4"); var txt1 = document.createTextNode("Epcot Center"); heading.appendChild(txt1); document.getElementById("myAside").appendChild(heading); var para = document.createElement("P"); var txt2 = document.createTextNode("The Epcot Center is a theme park in Disney World."); para.appendChild(txt2); document.getElementById("myAside").appendChild(para); } </script> </body> </html>