Skip to content

Instantly share code, notes, and snippets.

@macbookandrew
Created April 18, 2018 17:04
Show Gist options
  • Save macbookandrew/74fd6dd1d101debcf6890778052609d4 to your computer and use it in GitHub Desktop.
Save macbookandrew/74fd6dd1d101debcf6890778052609d4 to your computer and use it in GitHub Desktop.
_s theme: multiple menus on a page
/**
* Handle multiple menus on one page
*/
(function($){
$('document').ready(function(){
$('.main-navigation .menu-toggle').on('click', function(){
$(this).toggleClass('toggled');
var $nav = $(this).parents('.main-navigation'),
$ul = $nav.find('ul.menu');
if ($(this).hasClass('toggled')) {
$nav.toggleClass('toggled').attr('aria-expanded', true);
$ul.attr('aria-expanded', true);
} else {
$nav.toggleClass('toggled').attr('aria-expanded', false);
$ul.attr('aria-expanded', false);
}
});
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment