运行 ❯
获取您
的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <p>Click the button to create a DL, DT and DD element: a description list, with terms and descriptions.</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var x = document.createElement("DL"); x.setAttribute("id", "myDL"); document.body.appendChild(x); var y = document.createElement("DT"); var txt1 = document.createTextNode("Coffee"); y.appendChild(txt1); y.setAttribute("id", "myDT"); document.getElementById("myDL").appendChild(y); var z = document.createElement("DD"); var txt2 = document.createTextNode("Black hot drink"); z.appendChild(txt2); document.getElementById("myDL").appendChild(z); } </script> </body> </html>