Here is the HTML:
<ul class="drum">
<li>A</li>
<li>S</li>
<li>D</li>
</ul>
Here is the JS:
const Olist = document.querySelectorAll('.drum li');
for(let i = 0; i < Olist.length; i++){
Olist[i].addEventListener('click', function(e){
console.log(`I was clicked ${Olist[i]}`);
})
}
My console.log() inside the loop returns the following: I was clicked [object HTMLLIElement] I don't understand why am I getting [HTMLLIElement] and not the actual li
EDIT
I am trying to understand why am I not getting the same result as when I simply console.log(Olist[i]). I have done this many times in the past, but I think there is something fundamental that I am missing here.
console.log(`I was clicked ${Olist[i].innerHTML}`);