Created
February 8, 2018 19:03
-
-
Save michaelwhyte/32ad77c466c6a32f6d8cc8a45d897fc2 to your computer and use it in GitHub Desktop.
Make dropdown navigation bar keyboard 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
| const $nav = $('nav'); | |
| // The following JS modified from | |
| // JS found at this per: http://codepen.io/laviperchik/pen/dlcBt | |
| $.fn.accessibleDropDown = function () { | |
| var el = $(this); | |
| /* Make dropdown menus keyboard accessible */ | |
| el.find('a').focus(function() { | |
| $(this).parents("li").addClass("hover"); | |
| }).blur(function() { | |
| $(this).parents("li").removeClass("hover"); | |
| }); | |
| } | |
| $nav.accessibleDropDown(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment