Created
June 21, 2019 12:45
-
-
Save ruheni/7ee7862847ec75c0e77bdcf4081e7c05 to your computer and use it in GitHub Desktop.
jQuery __ https://www.taniarascia.com/responsive-dropdown-navigation-bar/ tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { // Begin jQuery | |
$(function() { // DOM ready | |
// If a link has a dropdown, add sub menu toggle. | |
$('nav ul li a:not(:only-child)').click(function(e) { | |
$(this).siblings('.nav-dropdown').toggle(); | |
// Close one dropdown when selecting another | |
$('.nav-dropdown').not($(this).siblings()).hide(); | |
e.stopPropagation(); | |
}); | |
// Clicking away from dropdown will remove the dropdown class | |
$('html').click(function() { | |
$('.nav-dropdown').hide(); | |
}); | |
// Toggle open and close nav styles on click | |
$('#nav-toggle').click(function() { | |
$('nav ul').slideToggle(); | |
}); | |
// Hamburger to X toggle | |
$('#nav-toggle').on('click', function() { | |
this.classList.toggle('active'); | |
}); | |
}); // end DOM ready | |
})(jQuery); // end jQuery |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment