7 * Finds the lowerst tabindex in use within a selection
9 * @return number Lowest tabindex on the page
11 $.fn.firstTabIndex = function () {
12 var minTabIndex = null;
13 $(this).find( '[tabindex]' ).each( function () {
14 var tabIndex = parseInt( $(this).prop( 'tabindex' ), 10 );
15 // In IE6/IE7 the above jQuery selector returns all elements,
16 // becuase it has a default value for tabIndex in IE6/IE7 of 0
17 // (rather than null/undefined). Therefore check "> 0" as well.
18 // Under IE7 under Windows NT 5.2 is also capable of returning NaN.
19 if ( tabIndex > 0 && !isNaN( tabIndex ) ) {
21 if ( minTabIndex === null ) {
22 minTabIndex = tabIndex;
23 } else if ( tabIndex < minTabIndex ) {
24 minTabIndex = tabIndex;
32 * Finds the highest tabindex in use within a selection
34 * @return number Highest tabindex on the page
36 $.fn.lastTabIndex = function () {
37 var maxTabIndex = null;
38 $(this).find( '[tabindex]' ).each( function () {
39 var tabIndex = parseInt( $(this).prop( 'tabindex' ), 10 );
40 if ( tabIndex > 0 && !isNaN( tabIndex ) ) {
42 if ( maxTabIndex === null ) {
43 maxTabIndex = tabIndex;
44 } else if ( tabIndex > maxTabIndex ) {
45 maxTabIndex = tabIndex;