javascript button add input to list item

Solutions on MaxInterview for javascript button add input to list item by the best coders in the world

showing results for - "javascript button add input to list item"
Dante
26 Oct 2020
1//Defining a listener for our button, specifically, an onclick handler
2document.getElementById("add").onclick = function() {
3    //First things first, we need our text:
4    var text = document.getElementById("idea").value; //.value gets input values
5
6    //Now construct a quick list element
7    var li = "<li>" + text + "</li>";
8
9    //Now use appendChild and add it to the list!
10    document.getElementById("list").appendChild(li);
11}
12