Created
February 27, 2014 10:56
-
-
Save nielk/9248074 to your computer and use it in GitHub Desktop.
menu accordéon accessible
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
/* click event & slide */ | |
/* http://alex-d.fr/blog/ordre-des-evenements-javascript-click-touch-focus-et-confreres */ | |
var click = false; | |
$('#menu li a').click( function() { | |
click = true; | |
var openMe = $(this).next(); | |
var mySiblings = $(this).parent().siblings().find('ul'); | |
if (openMe.is(':visible')) { | |
openMe.slideUp('normal'); | |
} else { | |
mySiblings.slideUp('normal'); | |
openMe.slideDown('normal'); | |
} | |
setTimeout(function() { | |
click = false; | |
}, 150); | |
}); | |
$('#menu li a').focus( function() { | |
setTimeout(function() { | |
if(!click) { | |
var openMe = $(this).next(); | |
var mySiblings = $(this).parent().siblings().find('ul'); | |
if (openMe.is(':visible')) { | |
openMe.slideUp('normal'); | |
} else { | |
mySiblings.slideUp('normal'); | |
openMe.slideDown('normal'); | |
} | |
} | |
click = false; | |
}, 100); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment