JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" id="input"></input><button id="btn">Submit</button><button id="abmArray">Show items in the console</button>
<ul id="list"></ul>
JavaScript
// Variables
var list = document.getElementById('list');
var input = document.getElementById("input");
var btn = document.getElementById("btn");
var showArray = document.getElementById("abmArray");
// Array that holds the input then will be thrown into the list
var aBM = ['This is a test', 'Adding more', 'one more'];
// onSubmit function will get input and display as list
btn.addEventListener('click', function(){
var item = input.value;
// this keeps the array from adding in blank values
if(item === ""){
return false;
} else {
aBM.push(item);
}
for(var i=0; i<aBM.length; i++){
list.innerHTML = ('<li>' + aBM[i] + '</li>');
}
});
// Show aBM
showArray.addEventListener('click', function(){
console.log(aBM);
});