Javascript examples for DOM HTML Element:Ol
You can create an <ol> element by using the document.createElement() method:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">create an OL element and a LI element</button> <p id="demo"></p> <script> function myFunction() {// w w w .j a v a 2 s . co m var x = document.createElement("OL"); x.setAttribute("id", "myOl"); document.body.appendChild(x); var y = document.createElement("LI"); var t = document.createTextNode("CSS"); y.appendChild(t); document.getElementById("myOl").appendChild(y); } </script> </body> </html>