Javascript DOM HTML UL append new <LI> element
<!DOCTYPE html> <html> <body> <ul id="myList"> <li>CSS</li> <li>HTML</li> </ul>/*from w ww . ja v a 2s . co m*/ <button onclick="myFunction()">Test</button> <script> function myFunction() { var node = document.createElement("LI"); var textnode = document.createTextNode("Water"); node.appendChild(textnode); document.getElementById("myList").appendChild(node); } </script> </body> </html>