Javascript examples for DOM HTML Element:DList
You can create a <dl> element by using the document.createElement() method:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">create a DL, DT and DD element: a description list, with terms and descriptions</button> <script> function myFunction() {//ww w.j a v a 2s . c o m var x = document.createElement("DL"); x.setAttribute("id", "myDL"); document.body.appendChild(x); var y = document.createElement("DT"); var txt1 = document.createTextNode("CSS"); y.appendChild(txt1); y.setAttribute("id", "myDT"); document.getElementById("myDL").appendChild(y); var z = document.createElement("DD"); var txt2 = document.createTextNode("for style"); z.appendChild(txt2); document.getElementById("myDL").appendChild(z); } </script> </body> </html>