Mouseover Event Listener | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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!

12th Jan 2019, 11:31 PM
Brian Oliver
Brian Oliver - avatar
2 Answers
+ 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👍
12th Jan 2019, 11:56 PM
🌴Vincent Berger🌴
🌴Vincent Berger🌴 - avatar
+ 1
Thank you Vincent Berger! That makes sense, I had my script at the bottom of the body tag in my text editor.
13th Jan 2019, 12:06 AM
Brian Oliver
Brian Oliver - avatar