+ 1
Mouseover Event Listener
Hey Guys, I currently made a simple JavaScript drop-down menu ,but when I copied the code over from my text editor into sololearn the console returns an error saying that my addEventListener is void. I don’t understand how it is void though. When I open the browser on my pc and run the script it works as intended with no error. Any help is greatly appreciated. Thanks in advance any advice! https://code.sololearn.com/WPKf64sRk8pe/?ref=app
2 Réponses
+ 2
Hi Brian Oliver,
SoloLearn executes the script in the head of the document.
Therefore the script will be loaded before the document.
For logic reasons the script will be executed first and therefore not able to get values from the DOM which will result in null(not an error).
A simple document load on the script will fix it.
Have a look at the changes👍
https://code.sololearn.com/W9xxG9zAbPPM/?ref=app
+ 1
Thank you Vincent Berger! That makes sense, I had my script at the bottom of the body tag in my text editor.