tabIndex property
Specifies or returns the tabbing order for keyboard navigation using the TAB key.
The default tabbing order matches the source order in the markup, with tabIndex you can change this order. The browser will tab to the elements in ascending order.
The another effect of the tabIndex property is that if it is specififed, the element can be active (can have focus). Most of the HTML elements cannot be active by default (div, span, ...), but if the tabIndex property is set on them, they can be active.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: tabIndex |
Possible values:
Integer that sets or retrieves the position of the element in the tabbing hierarchy. Default: 0. If the value is a negative number, the element will be removed from the tabbing hierarchy.
Default: 0.
Example HTML code 1:
This example illustrates the use of the tabIndex attribute:
|
||||
<input type="text" tabindex="1" value="Use the" /> <input type="text" value="TAB key" /> <input type="text" tabindex="2" value="to navigate" /> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates the use of the tabIndex property:
|
||||
<head> <script type="text/javascript"> function ChangeTab () { var inputs = document.getElementsByTagName ("input"); inputs[0].tabIndex = 3; inputs[1].tabIndex = 2; inputs[2].tabIndex = 1; } </script> </head> <body> <input type="text" tabindex="1" value="Use the" /> <input type="text" value="TAB key" /> <input type="text" tabindex="2" value="to navigate" /> <button onclick="ChangeTab ();">Change tabbing order!</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
HTML elements:
a, abbr, acronym, address, applet, area, b, bdo, big, blink, blockquote, body, br, button, caption, center, cite, code, dd, del, dfn, dir, div, dl, dt, em, embed, fieldset, font, form, frame, frameset, h1, h2, h3, h4, h5, h6, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:image, input:password, input:radio, input:range, input:reset, input:search, input:submit, input:text, ins, isindex, kbd, keygen, label, legend, li, listing, map, marquee, menu, nobr, noframes, object, ol, optgroup, option, p, plaintext, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tbody, td, textarea, tfoot, th, thead, tr, tt, u, ul, var, wbr, xmp
External links:
User Contributed Comments