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();
css-selectorsfocusjquery
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();
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/