thycooon
thycooon
KPCKevin Powell - Community
Created by thycooon on 2/17/2025 in #front-end
Why does the eventListener just works on the first occasion?
So from what I know, however many times I trigger the eventListener, it will always fire an event. Why does my eventListener does not do this? It doesn't even listen for it twice, but I have not set the option
element.addEventListener('click', () => {},{once: true})
element.addEventListener('click', () => {},{once: true})
... so I don't get why. No errors either. I'm lost for hours on it. Searched google up and down, can't find the same issue. Close issues where, if the person forgot to add the function as a callback and instead directly injected the function they wanna call. I did not do this. Maybe it's something close I don't get. Minimized my project to the smallest repeatable part and uploaded it here: https://jsfiddle.net/shknz67a/
28 replies