Skip to content

Instantly share code, notes, and snippets.

@amitkumar
Created March 15, 2016 19:14
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
/**
* 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