Jquery – How to select an element that has focus on it with jQuery


How can you select an element that has current focus?

There is no :focus filter in jQuery, that is why we can use something like this:


Best Solution

$(document.activeElement) will return the currently focused element and is faster than using the pseudo selector :focus.

Source: http://api.jquery.com/focus-selector/