Created
March 28, 2016 18:34
-
-
Save nborko/03c1f9be3bce55069287 to your computer and use it in GitHub Desktop.
jQuery shim to focus on any element regardless of tabindex
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
/* jquery shim to focus on any element regardless of tabindex */ | |
(function($) { | |
$.fn.focus = (function(focus) { | |
return function () { | |
if (arguments.length > 0) { | |
return focus.apply(this, arguments); | |
} | |
if (typeof $(this).attr('tabindex') === 'undefined') { | |
return focus.call(this.attr('tabindex', '-1')).removeAttr('tabindex'); | |
} | |
return focus.call(this); | |
}; | |
})($.fn.focus); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment