Answers for "javascript code to add items in dom"

0

javascript code to add items in dom

<body>
<label>Input:</label>
    <input type="text" id="myInput">
    <button onclick="add_Item()">ADD ITEMS</button>
    <div id="items"></div>
</body>
<script>
      function add_Item(){
var inpt=document.getElementById("myInput");
var para=document.createElement("p");
para.textContent=inpt.value;
var parent=document.getElementById("items");
parent.appendChild(para);
inpt.value="";
}

</script>
Posted by: Guest on August-23-2021

Code answers related to "javascript code to add items in dom"

Code answers related to "Javascript"

Browse Popular Code Answers by Language