Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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