After implementing a window scroll event listener, I have obtained a NodeList by using document.querySelectorAll. I am then iterating over this NodeList using forEach. Within the forEach loop, I am triggering a click event on each item. However, my click event is being triggered multiple times. How can I resolve this issue?
Important: Please test this code on the Vimeo home page.
window.addEventListener("scroll",()=>{
var config = document.querySelectorAll("[data-config-url]");
config.forEach((item)=>{
item.addEventListener("click",(e)=>{
var configData = e.currentTarget.getAttribute("data-config-url");
console.log(configData);
});
});
});
I only want to log the configData of each item once.