Skip to content

Instantly share code, notes, and snippets.

@koirikivi
Created December 21, 2018 14:43
Show Gist options
  • Save koirikivi/a7c4f33495375007479714497dedf8dc to your computer and use it in GitHub Desktop.
Save koirikivi/a7c4f33495375007479714497dedf8dc to your computer and use it in GitHub Desktop.
Getting next available tabindex with jQuery
function getNextAvailableTabIndex() {
var tabIndexes = $('[tabIndex]').map(function() {
return parseInt($(this).attr('tabindex'), 10);
}).toArray();
tabIndexes.push(0); // account for [] and [-1]
return Math.max.apply(null, tabIndexes) + 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment