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
5 odpowiedzi
+ 3
https://code.sololearn.com/W8HcB6so6dCG/?ref=app
+ 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.
+ 2
it's not jQuery
it's $
0
What do u mean?
0
Ohhh for sure!
Now I understand, thank you so much!