summaryrefslogtreecommitdiff
path: root/resources/jquery/jquery.tabIndex.js
blob: bb9b2bfae8de8401a06b210d9fe7538f24e614a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
 * jQuery tabIndex
 */
( function( $ ) {
/**
 * Finds the lowerst tabindex in use within a selection
 * 
 * @return Integer of lowest tabindex on the page
 */
jQuery.fn.firstTabIndex = function() {
	var minTabIndex = 0;
	jQuery(this).find( '[tabindex]' ).each( function() {
		var tabIndex = parseInt( jQuery(this).attr( 'tabindex' ) );
		if ( tabIndex > minTabIndex ) {
			minTabIndex = tabIndex;
		}
	} );
	return minTabIndex;
};
/**
 * Finds the highest tabindex in use within a selection
 * 
 * @return Integer of highest tabindex on the page
 */
jQuery.fn.lastTabIndex = function() {
	var maxTabIndex = 0;
	jQuery(this).find( '[tabindex]' ).each( function() {
		var tabIndex = parseInt( jQuery(this).attr( 'tabindex' ) );
		if ( tabIndex > maxTabIndex ) {
			maxTabIndex = tabIndex;
		}
	} );
	return maxTabIndex;
};
} )( jQuery );