2
I need to get the last 'tabindex' of a form for when the user clicks 'tab' or 'enter' back to the first.
Follows current code:
$(':input').keydown( function(event) {
if ( (event.which === 13 || event.which === 9) && !event.shiftKey ) {
node = $(this);
currentIndex = node.attr('tabindex');
// if ( currentIndex > 0 ) {
if ( currentIndex > 0 && currentIndex < **MAX_TABINDEX** )
event.preventDefault();
currentIndex++;
$('[tabindex=' + currentIndex + ']').focus();
$('[tabindex=' + currentIndex + ']').select();
} else {
$('[tabindex=1]').focus();
$('[tabindex=1]').select();
}
}
Any idea?
Or you can check if the last element is with Focus, if yes, by pressing TAB or ENTER sends Focus pro first...
– Franchesco
@Earendul how do I identify the last element? I mean, dynamically and not just by putting the name of the object, how? Something like 'last(':input');'
– Evert
Thus:
$("input:last")
. https://api.jquery.com/last/– Franchesco