jQuery global focus hook

In my focus manager I need to store some info on the last focus and blur. I need to delegate this hook to body, but if I use * as a filter I will receive the focus event for every parent item of the actual thing getting focus.

Realistically, I could make a filter to accept something like a, input, button … etc, but also I need to refine it to a:not([tabindex]=-1), *[tabindex!=-1] etc.

But this gets complicated when one considers disabled controls. Is there a jQuery selector for :focusable, or how do I work around this? I could debounce my function, but even that is iffy.

EDIT:
Alright, my bad, I think what I am looking for here is :tabbable.


Source: jquery

Leave a Reply