Skip to content

Instantly share code, notes, and snippets.

@lou
Created July 27, 2010 14:35
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 lou/492304 to your computer and use it in GitHub Desktop.
Save lou/492304 to your computer and use it in GitHub Desktop.
$(document).click(function(e) {
if ($(e.target).closest('.toggle').length > 0){
e.preventDefault();
var target = target.closest('.toggle');
if (target.hasClass('menuOn')){
$('.toggle').removeClass('menuOn');
target.closest('.dropdown').find('.menu').hide('fast');
} else {
$('.toggle').removeClass('menuOn');
$('.dropdown .menu').hide();
target.addClass('menuOn');
target.closest('.dropdown').find('.menu').show('fast');
}
} else {
if ($(e.target).parents('.menu').length == 0){
$('h3 .toggle').removeClass('menuOn');
$('.dropdown .menu').hide();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment