THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

HTML DOM tabIndex Property

HTMLElement Object Reference Element Object

Example

Change the tab order for three links:

document.getElementById("myAnchor1").tabIndex = "3";
document.getElementById("myAnchor2").tabIndex = "2";
document.getElementById("myAnchor3").tabIndex = "1";
Try it yourself »

More "Try it Yourself" examples below.


Definition and Usage

The tabIndex property sets or returns the value of the tabindex attribute of an element.

The tabindex attribute specifies the tab order of an element (when the "tab" button is used for navigating).


Browser Support

Property
tabIndex Yes Yes Yes Yes Yes

Syntax

Return the tabIndex property:

HTMLElementObject.tabIndex

Set the tabIndex property:

HTMLElementObject.tabIndex=number

Property Values

Value Description
number Specifies the tabbing order of the element (1 is first).

Note: If the number negative, the element will be removed from the tab order

Technical Details

Return Value: A Number, representing the tab order of the element

Examples

More Examples

Example

Get the tab order of the first <a> element (index 0) in the document:

var x = document.getElementsByTagName("A")[0].tabIndex;
document.getElementById("demo").innerHTML = x;

The result of x will be:

2
Try it yourself »

Related Pages

HTML reference: HTML tabindex Attribute


HTMLElement Object Reference Element Object