0

Error undefined

Here is my web code. It tells me menu is undefined, why? https://code.sololearn.com/WJvBk9LiVpJQ/?ref=app

8th Jan 2020, 11:03 PM
Mohamed Habib
Mohamed Habib - avatar
5 ответов
+ 7
The JavaScript file in SoloLearn is included at the top of the html file, before the body tag is even created. So when you run it first, there is no body tag yet, and thus the error. If you try this in your computer, and link the JavaScript file at the bottom, it should work fine.
8th Jan 2020, 11:07 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 5
Mohamed Habib you sadly can't include the JS file manually in SL, so no, it will not work. Try to wrap it in window.onload function
8th Jan 2020, 11:10 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
8th Jan 2020, 11:11 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 2
Ok thanks a lot 👌
8th Jan 2020, 11:11 PM
Mohamed Habib
Mohamed Habib - avatar
8th Jan 2020, 11:12 PM
Mohamed Habib
Mohamed Habib - avatar