Skip to content
Snippets Groups Projects

Divinity Megazord Menu Accessibility helper

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Joel Crawford-Smith

    This will add the aria-expanded attributes to the menu. It will keep the attribute's value (true/false) to accurately describe the visibility of the submenu.

    It should be in a document.ready like all jQuery code. You can change the jQuery prefix to $ if you want. Its just using the jQuery prefix so it works if you paste it in the browsers console.

    Edited
    megazord-a11y-helper.js 491 B
    jQuery('#menuzord-menu > li > a').attr('aria-expanded', 'false').attr('role', 'button');
    jQuery('#menuzord-menu > li > a').bind('click', function (e) {
        var expandedState = jQuery(this).attr('aria-expanded');
    
        if (expandedState == 'true') { 
            jQuery(this).attr('aria-expanded', 'false');
        }
        if (expandedState == 'false') {
            jQuery(this).attr('aria-expanded', 'true');
            jQuery(this).parent().siblings().find('> a').attr('aria-expanded', 'false');
        }
    });
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment