showing results for - "javascript code to add items in dom"
Paulina
24 Jul 2017
1<body>
2<label>Input:</label>
3    <input type="text" id="myInput">
4    <button onclick="add_Item()">ADD ITEMS</button>
5    <div id="items"></div>
6</body>
7<script>
8      function add_Item(){
9var inpt=document.getElementById("myInput");
10var para=document.createElement("p");
11para.textContent=inpt.value;
12var parent=document.getElementById("items");
13parent.appendChild(para);
14inpt.value="";
15}
16
17</script>