Is there something I can do like this (perhap via a plugin)
if ( ! $(\'form#contact input]\').hasFocus()) {
$(\'form#contact input:first]\').focus();
}
$('*:focus')
(Necro ftw, but still valid and useful)
Here is a succinct way to do it.
$(document.activeElement)
or to plug it into your example..
if ($('form#contact input]')[0]!=$(document.activeElement)) { ... }
jQuery 1.6 now has a dedicated :focus selector.
No, there isn't.
However, you can simulate it like this:
$(':input')
.data('focused', false)
.focus(function() { $.data(this, 'focused', true); })
.blur(function() { $.data(this, 'focused', false); });