How do I generate a list of textboxes in JavaScript? -
i'm making js application automatically textbox on user input. i'm not sure how append input
li
the end result want @ this:
<ul id="lst"> <li>item1: <input type="text"></li> <li>item2: <input type="text"></li> <!-- more li added on button press --> </ul>
what got far this:
var onclick = function() { var ul = document.getelementbyid('lst'), li = document.createelement('li'); li.appendchild(document.createtextnode('item' + counter + ': ')); counter++; ul.appendchild(li); }
how append <input type="text">
node?
the same way added text element.
var onclick = function() { var ul = document.getelementbyid('lst'), li = document.createelement('li'), input = document.createelement('input'); input.type="text"; li.appendchild(document.createtextnode('item' + counter + ': ')); li.appendchild(input); counter++; ul.appendchild(li); }
Comments
Post a Comment