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:
$('input:focus').someFunction();
If you use JQuery, you can write a selector like this:
$.expr[':'].focus = function(a){ return (a == document.activeElement); }
You can then select the currently focused element: $(":focus")
Not only form controls can have focus. Any html element with a tabindex can be focused in modern browsers.
$(':focus')
to find the element currently focused in the current document. – Alexis Wilke