<ul id="userList"></ul>
var list = document.getElementById("userList");
var names = ["Joe", "Kim", "Dave", "Ron", "Bill"];
names.forEach(function(name) {
var listItem = document.createElement("li");
listItem.innerText = name;
listItem.onclick = function() {
alert(name);
}
list.appendChild(listItem)
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.