Skip to content

Instantly share code, notes, and snippets.

@netviperinc
Last active August 29, 2015 14:23
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 netviperinc/eb9abe627e548ce2d2f3 to your computer and use it in GitHub Desktop.
Save netviperinc/eb9abe627e548ce2d2f3 to your computer and use it in GitHub Desktop.
( function( window, $, undefined ) {
'use strict';
$( 'nav' ).before( '<button class="c-hamburger c-hamburger--htx" role="button" aria-pressed="false"><span>toggle menu</span></button>' ); // Add toggles to menus
$( 'nav .sub-menu' ).before( '<button class="sub-menu-toggle" role="button" aria-pressed="false"></button>' ); // Add toggles to sub menus
// Show/hide the navigation
$( '.c-hamburger, .sub-menu-toggle' ).on( 'click', function() {
var $this = $( this );
$this.attr( 'aria-pressed', function( index, value ) {
return 'false' === value ? 'true' : 'false';
});
$this.toggleClass( 'is-active' );
$this.next( 'nav, .sub-menu' ).slideToggle( 'fast' );
});
})( this, jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment