Skip to content

Instantly share code, notes, and snippets.

@gotoplanb
Created September 4, 2013 17:50
Show Gist options
  • Save gotoplanb/6440348 to your computer and use it in GitHub Desktop.
Save gotoplanb/6440348 to your computer and use it in GitHub Desktop.
<!-- need one for each toplevel nav item. search the demo -->
<i data-js="nav-dropdown-trigger" class="icon-caret-down nav-dropdown-trigger"></i>
<!-- one of these -->
<i data-js="nav-trigger" class="icon-reorder nav-trigger"></i>
<!-- put into js -->
<script>
$(document).ready(function() {
/* Mobile navigation dropdown */
$('i[data-js="nav-trigger"]').click(function() {
$(this).toggleClass('active');
$('.navPrimary').toggleClass('open');
$('.navPrimary-list-item').removeClass('open');
});
$('i[data-js="nav-dropdown-trigger"]').click(function() {
if ($(this).parent('.navPrimary-list-item').hasClass('open')) {
$('.navPrimary-list-item').removeClass('open');
} else {
$('.navPrimary-list-item').removeClass('open');
$(this).parent().addClass('open');
}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment