Звучит так, как будто вы всегда хотите, чтобы один из ваших входов был сфокусированным, достаточно справедливым.Я бы сделал так, чтобы связать каждое из ваших входных событий blur()
так, чтобы в случае его возникновения он переходил к следующему элементу.
Вот разметка:
<body>
<form method="POST" action=".">
<input type="text" name="username" />
<input type="password" name="password" />
<input type="submit" name="submit" />
</form>
</body>
Ивот jQuery:
$(document).ready(function() {
// what are the named fields the user may focus on?
var allowed = ['username', 'password', 'submit'];
$.each(allowed, function(i, val) {
var next = (i + 1) % allowed.length;
$('input[name='+val+']').bind('blur', function(){
$('input[name='+allowed[next]+']').focus();
});
});
$('input[name='+allowed[0]+']').focus();
});