Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript button add input to list item

//Defining a listener for our button, specifically, an onclick handler
document.getElementById("add").onclick = function() {
    //First things first, we need our text:
    var text = document.getElementById("idea").value; //.value gets input values

    //Now construct a quick list element
    var li = "<li>" + text + "</li>";

    //Now use appendChild and add it to the list!
    document.getElementById("list").appendChild(li);
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: while vs do while javascript 
Javascript :: javascript async function 
Javascript :: change p text jqwuery 
Javascript :: javascript console log whole array 
Javascript :: print all days names of a month 
Javascript :: string uppercase 
Javascript :: angularjs datetime 
Javascript :: react router get data from url 
Javascript :: image upload react 
Javascript :: how to save and use item from local storage javascript 
Javascript :: loop through array in javascript 
Javascript :: increased the value of a counter when a button is clicked in js 
Javascript :: js object using variable as key 
Javascript :: jquery set select value 
Javascript :: How to get current time zone in javascript 
Javascript :: select in react js 
Javascript :: js execute string 
Javascript :: express router file 
Javascript :: preloader 
Javascript :: scroll to top 
Javascript :: complete math objects in javascript 
Javascript :: vue js cdn 
Javascript :: vue router refresh page not found 
Javascript :: javascript execute function by string name 
Javascript :: form data object 
Javascript :: If statement discord js 
Javascript :: npm is not recognized 
Javascript :: how to use console.log in vuejs 
Javascript :: javascript loop x times 
Javascript :: usereducer hook 
ADD CONTENT
Topic
Content
Source link
Name
9+2 =