0
I was following a project in a tutorial and I bumped into this problem, as you know in tutorials not explain the mistakes of things so I came here, I’m still learning.
addEventListenerAll(element, events, fn){
events.split(' ').forEach(event => { //ERRO
element.addEventListener(event, fn, false)
})
}
initButtonsEvents(){
let buttons = document.querySelectorAll('#buttons > g, #parts > g')
buttons.forEach((btn, index)=>{
this.addEventListenerAll(btn, 'click drag', e => {
console.log(btn.className.baseVal.replace('btn-', ''))
})
})
}
Dear Stenio, the code seems correct, probably is something else or elsewhere, has no sense your code, it is probably not even JS, should be typescript, we need q vc explain better how this running, because here it worked normally.
– Guilherme Nascimento
When so it is good to research the error right here on the site. It has an immense amount of similar questions and answers (it shouldn’t even have so many, actually). Duplicate content is not beneficial to our template. And whenever you post something, provide a [mcve]. Studying the post available on this link can make a very positive difference in your use of the site: Stack Overflow Survival Guide in English
– Bacco