[SOLVED] Menu Drop, I need help with CSS and Java. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

[SOLVED] Menu Drop, I need help with CSS and Java.

I made a website, I need help because in my computer the jQuery works well when I use the Menu Drop, but when I use the same code here, it isn't work. This is the JS code: jQuery('document').ready(function(menuDrop) { var menuBtn =menuDrop('#main-menu-drop'), menu =menuDrop('#main-menu ul'); menuBtn.click(function() { if(menu.hasClass('show')) { menu.removeClass('show'); } else { menu.addClass('show'); } }); }); • This is the code: https://code.sololearn.com/WIGewwDu7SCS

26th Apr 2020, 5:30 AM
Diego Fernandez
Diego Fernandez - avatar
5 Answers
+ 3
https://code.sololearn.com/W8HcB6so6dCG/?ref=app
26th Apr 2020, 5:41 AM
Gordon
Gordon - avatar
+ 3
i have to correct my explanation. It's because the sequence of running script. Because scripts in JS tab are added to <head> and your document ready is running before loading jQuery library, so there was the error "jQuery is not defined" I solved it by moving the script in JS tab to just before </body> to ensure jQuery exists before being used.
26th Apr 2020, 5:46 AM
Gordon
Gordon - avatar
+ 2
it's not jQuery it's $
26th Apr 2020, 5:39 AM
Gordon
Gordon - avatar
0
What do u mean?
26th Apr 2020, 5:40 AM
Diego Fernandez
Diego Fernandez - avatar
0
Ohhh for sure! Now I understand, thank you so much!
26th Apr 2020, 5:42 AM
Diego Fernandez
Diego Fernandez - avatar