Skip to content

Instantly share code, notes, and snippets.

@lancewillett
Created August 23, 2012 16:57
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 lancewillett/3438707 to your computer and use it in GitHub Desktop.
Save lancewillett/3438707 to your computer and use it in GitHub Desktop.
/**
* navigation.js
*
* Handles toggling the navigation menu for small screens.
*/
( function() {
var button = document.getElementById( 'site-navigation' ).getElementsByTagName( 'h3' )[0],
menu = document.getElementById( 'site-navigation' ).getElementsByTagName( 'ul' )[0];
button.onclick = function() {
if ( button.className.match( new RegExp( '(\\s|^)toggled-on(\\s|$)' ) ) ) {
button.className = 'menu-toggle';
menu.className = 'nav-menu';
} else {
button.className = 'menu-toggle toggled-on';
menu.className = 'nav-menu toggled-on';
}
};
} )();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment