how to add event listener in for eacth function code example
Example: how to add event listener to all buttons
//HTML
//JavaScript
var buttons = document.querySelectorAll(".btn").length;
for (var i = 0; i < buttons ; i++) {
document.querySelectorAll(".btn")[i].addEventListener("click", function() {
alert("Button Clicked");
});
}