I'm struggling about selecting a particular index of an element inside an array on click. Here's that peace of code and thanks in advance!
<div>
<span class="dot"></span>
<span class="dot"></span> -- lets say we click on this span
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>
var dots = document.querySelectorAll(".dot");
for(var i = 0; i < dots.length; i ++){
dots[i].addEventListener("click", function(){
console.log(this) -- prints the actual html <span class="dot"></span>
// ?? How to print index of an element? To be more specific, in this case
just "1" ??
})
}