Is there a 'has focus' in JavaScript (or jQuery)?
- by alex
Is there something I can do like this (perhap via a plugin)
if ( ! $('form#contact input]').hasFocus()) {
$('form#contact input:first]').focus();
}
Basically, set focus to the first input, but only if the user has not already clicked into anything?
I know this will work too, but is there anything more elegant?
$(function() {
var focused = FALSE:
$('form#contact input]').focus(function() {
focused = TRUE;
});
setTimeout(function() {
if ( ! focused) {
$('form#contact input:first]').focus();
};
}, 500);
});