Skip to content

Instantly share code, notes, and snippets.

@rudyjahchan
Created January 3, 2017 22:03
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 rudyjahchan/630944a506523c0940f9377f1c81c2e5 to your computer and use it in GitHub Desktop.
Save rudyjahchan/630944a506523c0940f9377f1c81c2e5 to your computer and use it in GitHub Desktop.
jQuery(($) => {
$("#menu-toggle").click((evt) => {
evt.preventDefault();
$('.menu-activable').toggleClass('menu-active');
return false;
});
});
function toggleMenuActive(element) {
element.classList.toggle('menu-active');
}
function onMenuClick(event) {
event.preventDefault();
const activableElements = document.getElementsByClassName('menu-activable');
Array.prototype.forEach.call(activableElements, toggleMenuActive);
return false;
}
document.addEventListener("DOMContentLoaded", function(event) {
const toggle = document.getElementById('menu-toggle');
toggle.addEventListener('click', onMenuClick);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment