Reputation: 8980
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.
Upvotes: 5
Views: 3481
Reputation: 855
With Javascript:
var maxTabIndex = -1;
document.getElementById("formID").querySelectorAll("input").forEach((e) => {
if (!isNaN(e.tabIndex)) {
if (e.tabIndex > maxTabIndex) {
maxTabIndex = e.tabIndex;
}
}
});
Upvotes: 0
Reputation: 23396
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.
Upvotes: 11