Skip to content

Instantly share code, notes, and snippets.

@generatepress
Created October 5, 2015 07:24
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save generatepress/d8211a277d13fa095849 to your computer and use it in GitHub Desktop.
Save generatepress/d8211a277d13fa095849 to your computer and use it in GitHub Desktop.
Make the mobile menu slide up and down
<script>
jQuery( document ).ready( function( $ ) {
$( '.menu-toggle' ).addClass( 'closed' );
$( document ).on( 'click', '.menu-toggle.closed', function() {
var sub = $( this ).next( '.main-nav' ).children( 'ul' );
sub.hide();
sub.slideDown();
$( this ).removeClass( 'closed' );
$( this ).addClass( 'opened' );
});
$( document ).on( 'click', '.menu-toggle.opened', function() {
var sub = $( this ).next( '.main-nav' ).children( 'ul' );
sub.slideUp();
$( this ).removeClass( 'opened' );
$( this ).addClass( 'closed' );
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment