Skip to content

Instantly share code, notes, and snippets.

@timrwood
Created March 30, 2013 21:13
Show Gist options
  • Save timrwood/5278356 to your computer and use it in GitHub Desktop.
Save timrwood/5278356 to your computer and use it in GitHub Desktop.
Active class on click.
var nav = $('nav');
$(window).on('click', function (e) {
// we clicked inside the nav
if ($(e.target).closest(nav).length) {
nav.addClass('active');
} else {
nav.removeClass('active');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment