0
How do I pass arguments into an eventListener in JavaScript efficiently?
Here is the problem: I want to assign just a single eventListener to 3 different div elements and pass in a function into the eventListener that executes differently based on the id of each div. The problem is that the program tells me instead that it can't read the id attribute of 'undefined'. Here is the code: https://code.sololearn.com/W0Jn3lLeL5L0/?ref=app
2 Respuestas
+ 3
modified your code.
you have what you need now
https://code.sololearn.com/WT8klzzt9vL3/?ref=app
0
᠌᠌brains Thanks a lot!
I also found out just now through a random guess that replacing alert(divs[i].id); with alert(this.id); gave the same effect. I Don't know what the difference is, but I'm so happy! ☺️