Javascript examples for DOM HTML Element:Ul
You can create a <ul> element by using the document.createElement() method:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">create a UL and LI element</button> <script> function myFunction() {/*from ww w.j a v a 2s.c om*/ var x = document.createElement("UL"); x.setAttribute("id", "myUL"); document.body.appendChild(x); var y = document.createElement("LI"); var t = document.createTextNode("Tea"); y.appendChild(t); document.getElementById("myUL").appendChild(y); } </script> </body> </html>