amberweinberg

Accessibile WordPress Dropdown Menus

Dec 12th, 2019
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var desktop = $('header li a');
  2.     $('.sub-menu').attr('aria-expanded', 'false');
  3.        
  4.     function desktopFiltering() {
  5.        
  6.         desktop.bind("focus", function(event) {
  7.            
  8.             $(this).parent().siblings().removeClass('active').find('.sub-menu').attr('aria-expanded', 'false');
  9.            
  10.             if($(this).parent().hasClass('active')) {
  11.                
  12.                 $(this).next().find('li:first-child a').focus();
  13.                
  14.             } else {
  15.                
  16.                 $(this).parent().addClass('active');
  17.                 $(this).next().attr('aria-expanded', 'true');
  18.                
  19.             }
  20.        
  21.         });
  22.  
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment