Created
March 15, 2016 19:14
-
-
Save amitkumar/9e07be8e3872ec165cd9 to your computer and use it in GitHub Desktop.
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
/** | |
* 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