Bro! Put a F*cking dot before "menu-icon". Should be var menuIcon = document.querySelector(".menu-icon"); if you're selecting a class.Hello Everyone,
I going to try to explain as short and simple as possible.
So, recently I was programming a javascript for my website, but something went wrong...
The javascript does not show up on the website.
I watched countless of videos of this problem, but nothing solves it.
I also tried to rewrite the code several times as well.
-------------------------------------------------------------------------
(I am using "Visual Studio Code")
1: I made a new file called (script.js)
2: I wrote this in:
var menuIcon = document.querySelector("menu-icon");
var sidebar = document.querySelector(".sidebar");
menuIcon.onclick = function(){
const newLocal = "small-sidebar";
sidebar.classList.toggle();
}
3: I then connected this file to the index.html
--------------------------------------------------------------------
But STILL it does not work.
Do you see anything wrong here?
Also specify in brackets what class you want to add/remove in .toggle("YOUR CLASS GOES HERE")