Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find Max tabindex Within Form

Using jQuery/Javascript, how do I find the maximum tabindex value that exists on a given form #formID?

And before you ask (because I know people will) I haven't tried anything because I really have no idea where to begin.

like image 728
FastTrack Avatar asked Dec 20 '22 08:12

FastTrack


1 Answers

This is one way:

var max = -1;
$('#formID [tabindex]').attr('tabindex', function (a, b) {
    max = Math.max(max, +b);
});

max = -1 indicates, that there's no tabindexes in the form, or elements are excluded from tabbing order.

A live demo at jsFiddle.

like image 80
Teemu Avatar answered Dec 30 '22 18:12

Teemu