+ 1
I have created a navbar. But my javascript code not working. I don't what to do... Can anyone please help me.
const hamburger = document.querySelector(".hamburger"); const navLinks = document.querySelector(".nav-links"); const links = document.querySelectorAll(".nav-links li"); hamburger.addEventListener("click", () => { navLinks.classList.toggle("open"); links.forEach(link => { link.classList.toggle("fade"); }); }); https://code.sololearn.com/Wl55UpXP6y42/?ref=app
2 Antworten
+ 2
Sourav Chakraborty Write your JavaScript code inside this function
window.onload = function() {
}
+ 2
window.onload=function(){
js code goes here
}
it prevents js from getting loaded before html