HTML DOM Element tabIndex

Examples

Change the tab order for 3 links:

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

Get the tab order of the first <a> element:

let order = document.getElementsByTagName("A")[0].tabIndex;
Try it Yourself »

Description

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.


Syntax

Return the tabIndex property:

element.tabIndex

Set the tabIndex property:

element.tabIndex = number

Return Value

Type Description
number Tab order of the element (1 is first).
If the number is negative, the element is removed from the tab order.

Return Value

Type Description
NumberThe tab order of the element.

Browser Support

element.tabIndex is supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes Yes

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.