Created
November 6, 2014 09:36
-
-
Save goncharov/49a01307aeea79cd32c3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// HEADER DROPDOWN MENUS | |
// Close dd on click if active | |
$('.shortcuts dl').click(function(e) { | |
if ($(this).hasClass('active')) { | |
$('.shortcuts dl').removeClass('active'); | |
$('.shortcuts dl dt > span').removeClass('opened'); | |
$(this).children('dd').hide(); | |
} | |
// Open dd on click if not active | |
else { | |
$('.shortcuts dl').removeClass('active'); | |
$('.shortcuts dl dt > span').removeClass('opened'); | |
$('.shortcuts dl').children('dd').hide(); | |
$(this).children('dd').show(); | |
$(this).find('dt > span').addClass('opened'); | |
$(this).addClass('active'); | |
} | |
e.stopPropagation(); | |
}); | |
// Don't close dd when clicked on dd element | |
$('.shortcuts dl dd').click(function(e) { | |
e.stopPropagation(); | |
}); | |
// Close dd when clicked outside | |
$(document).click(function() { | |
$(".shortcuts dl dd").hide(); | |
$('.shortcuts dl').removeClass('active'); | |
$('.shortcuts dl dt > span').removeClass('opened'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment