This file contains 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
/** | |
* Disable or enable focus on all focusable elements. Useful for proper keyboard navigation | |
* of slide-based interfaces where certain slides are hidden/shown based on user interaction. | |
* Assumes jQuery. | |
* | |
* @param {jQuery object} $el - jQuery object whose children will be toggled | |
* @param {bool} enable | |
* / | |
var toggleFocusableElements = function($el, enable){ | |
if (enable){ | |
$el.find('input,button,a,[role="button"],[role="checkbox"],[tabindex]').attr('tabindex', '0'); | |
} else { | |
$el.find('input,button,a,[role="button"],[role="checkbox"],[tabindex]').attr('tabindex', '-1'); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment