How can I Create a Dynamic HTML List
Add Item
Item 1
Item 2
HTML Code
<button onclick="addelement();">Add Item</button> <br/><br/> <ul id="thelist"> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul>
Javascript Code
<script> var counter= 3; function addelement() { var completelist= document.getElementById("thelist"); completelist.innerHTML += "<li>Item " + counter + "</li>"; counter++; } </script>