Currently, you're firing a click event for each of the HTMLElement
s in theNodeList
(sliderControler
).
Each of the elements of the NodeList
is an HTMLElement
. To bind a click handler to the elements in the NodeList use addEventListener
or assign the handler to the onclick
property.
for(i = 0; i < sliderControler.length;i++) {
sliderControler[i].addEventListener('click', function(){
console.log("I love js");
});
}
If you're using jQuery, you don't need to use a loop to bind a click handler.
$('.sliderControler').click(function() {
console.log("I love js");
});