How to select an item when clicking on it?

How to select an item when clicking on it? If on the first or second hit.
f8JH76RSscM.jpg
let setUseChst=document.getElementsByClassName('app')[0];
setUseChst.addEventListener('click', () => {
 let elems = document.querySelectorAll('.user');
 for (let i = 0; i < elems.length; i++) {
console.info(elems)
 elems[i].onclick =function (){


}
}
});
April 3rd 20 at 17:45
2 answers
April 3rd 20 at 17:47
Solution
this
April 3rd 20 at 17:49
Solution
const usersNode = document.querySelectorAll(".user");

usersNode.forEach(user => {
 user.addEventListener("click", click, false);
});

function click() {
console.log(this);
}

Find more questions by tags JavaScript