Skip to content

Instantly share code, notes, and snippets.

@jsrath
Last active November 3, 2018 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsrath/737bbcfd379300f3048283718b5010b7 to your computer and use it in GitHub Desktop.
Save jsrath/737bbcfd379300f3048283718b5010b7 to your computer and use it in GitHub Desktop.
const mainNav = document.querySelector('.main-nav');
const menu = document.querySelector('#menu');
toggleMenu = () => {
mainNav.classList.toggle('isDisplayed');
if (menu.getAttribute('src') === './images/menu.svg') {
menu.setAttribute('src', './images/menu-purple.svg');
} else {
menu.setAttribute('src', './images/menu.svg');
}
};
menu.addEventListener('click', toggleMenu);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment