<ul class="list-group">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
const li = document.querySelectorAll('.list-group li');
li.forEach(function(e,k){
e.addEventListener('click',function(){
console.log(k);
});
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.