X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

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

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook