This is one way:
var max = -1;
$('#formID [tabindex]').attr('tabindex', function (a, b) {
max = Math.max(max, +b);
});
max = -1
indicates that there are no tabindexes in the form, or that elements are excluded from the tab order.
Live demo at jsFiddle .
Teemu
source
to share