Last active
September 23, 2017 14:09
-
-
Save DevShahidul/dff6532a32dd57b33f92aeca0705f4d8 to your computer and use it in GitHub Desktop.
This code for drop down navigation function
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
$('.main-nav ul li, .footer-nav-mobi ul li').find('ul').addClass('dropdownNav') | |
$('.main-nav ul li, .footer-nav-mobi ul li').find('ul').parent().addClass('hasDropdown') | |
if($(window).width() < 768){ | |
$('.main-nav ul li.hasDropdown > a, .footer-nav-mobi ul li.hasDropdown a').bind('click','touchend', function(e){ | |
e.preventDefault() | |
$('.main-nav li.hasDropdown, .footer-nav-mobi ul li.hasDropdown').removeClass('active') | |
$(this).parent().addClass('active') | |
$('.main-nav li.hasDropdown, .footer-nav-mobi ul li.hasDropdown').find('> ul:visible').slideUp() | |
if($(this).parent().find('> ul:visible').length){ | |
$(this).parent().find('> ul').slideUp() | |
$(this).parent().removeClass('active') | |
} | |
else{ | |
$(this).parent().find('> ul').slideDown() | |
$(this).parent().addClass('active') | |
} | |
}) | |
} | |
//Another one | |
if( $(window).width() < 768 ){ | |
$('.main-nav li.hasSubnav > a').bind('click', 'touchend', function(e){ | |
e.preventDefault() | |
$('.main-nav li.hasSubnav').find('> ul:visible').slideUp() | |
if( $(this).parent().find('> ul:visible').length ){ | |
$(this).parent().find('> ul').slideUp() | |
} | |
else{ | |
$(this).parent().find('> ul').slideDown() | |
} | |
}) | |
$('.main-nav li.hasSubmenu > a').bind('click', 'touchend', function(e){ | |
e.preventDefault() | |
$('.main-nav li.hasSubmenu').find('> ul:visible').slideUp() | |
if( $(this).parent().find('> ul:visible').length ){ | |
$(this).parent().find('> ul').slideUp() | |
} | |
else{ | |
$(this).parent().find('> ul').slideDown() | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment