Skip to content

Instantly share code, notes, and snippets.

@josiahwiebe
Created November 13, 2015 20:03
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 josiahwiebe/5face07c3763edc160c4 to your computer and use it in GitHub Desktop.
Save josiahwiebe/5face07c3763edc160c4 to your computer and use it in GitHub Desktop.
Make clicked nav item active while deactivating all others
$(document).ready(function() {
$('nav ul li').click(function(e) { // when clicking on the first level li
$('nav ul li div').removeClass('menu-is-visible'); // first remove the visible class any child div
$(this).children('div').addClass('menu-is-visible'); // then add the visible class to the current child div
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment