I’m working on a web-app in HTML and JS and I need to catch the clicks on each listItem of a list.
The list is dynamically created in a for-loop as follows:
var i = document.createElement("li");
i.innerHTML = "something"
uList.appendChild(i);
How can I make listItems clickable or catch clicks on each of them separately (get the specific item clicked)?
I’ve tried adding an eventListener on the list, and then isolate the target of the event (click). The problem is that this would count as many clicks as the size of the list.