Skip to content

Instantly share code, notes, and snippets.

@harmstyler
Created August 2, 2013 16:13
Show Gist options
  • Save harmstyler/6141155 to your computer and use it in GitHub Desktop.
Save harmstyler/6141155 to your computer and use it in GitHub Desktop.
Keyboard accessible dropdown menu.
$.fn.accessibleDropDown = ->
el = $(this);
enter = -> $(this).addClass('hover')
leave = -> $(this).removeClass('hover')
# Hover dropdown
$("li", el).hoverIntent(enter,leave)
# Make dropdown menus keyboard accessible
$("a", el).focus( ->
$(this).parents("li").addClass("hover");
).blur ->
$(this).parents("li").removeClass("hover");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment