const hamburger = document.querySelector(".hamburger"); const navLinks = document.querySelector(".nav-links"); const links = document.querySelectorAll(".nav-links li"); hamburger.addEventListener('click', ()=>{ //Animate Links navLinks.classList.toggle("open"); links.forEach(link => { link.classList.toggle("fade"); }); //Hamburger Animation hamburger.classList.toggle("toggle"); });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter