Javascript examples for DOM HTML Element:Option
HTML for loop inside ul element, insert <option> element to UL
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from w w w . j ava2 s. c o m*/ (function() { var list = document.getElementById('dynamicList'); for (var i = 0; i < 5; i++) { var li = document.createElement('li'); li.innerHTML = i; list.appendChild(li); } })(); } </script> </head> <body> <h1>Dynamic List Example</h1> <ul id="dynamicList"></ul> </body> </html>