In the following example code, I attach an onclick
event handler to the span containing the text \"foo\". The handler is an anonymous function that pops up an <
The easiest way is to use an array and push elements into it and then insert the array subsequent values into the array dynamically. Here is my code:
var namesArray = [];
function myclick(){
var readhere = prompt ("Insert value");
namesArray.push(readhere);
document.getElementById('demo').innerHTML= namesArray;
}