HTML | DOM tabIndex Property

The tabIndex property is used to return the value of the tabindex attribute of an element. The tabindex attribute specifies the tab order of an element (It is used when the tab button is used for navigating.)

Syntax:

  • Returns the tabIndex property:
    HTMLElementObject.tabIndex
  • Set the tabIndex property:
    HTMLElementObject.tabIndex = number

Property Values:

  • number: Define the tabbing order of the element.

Note: The element will be removed from the tab order if the number is negative.

Example:



filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
  
<head
    <title>HTML DOM tabIndex Property</title
      
    <style
        body { 
            text-align:center; 
        
        h1 { 
            color:green; 
        
        a { 
            text-decoration:none; 
        
    </style
</head
  
<body
    <h1>GeeksforGeeks</h1
      
    <h2>tabindex attribute</h2
      
            tabindex="2">
        Geeks HTML ide
    </a
    <br
      
                tabindex="1"
        GeeksforGeeks 
    </a
    <br
      
            tabindex="3"
        Geeks ide 
    </a><br>
      
    <button onclick="gfgFun()">Try it</button>
    <p id="gfg"></p>
  
    <script>
        function gfgFun() {
            var gfgvar = document.getElementsByTagName(
                        "A")[0].tabIndex;
                          
            document.getElementById("gfg").innerHTML
                        = gfgvar;
        }
    </script>
</body>
  
</html>

chevron_right


Output:

Supported Browsers: The browser supported by HTML DOM tabIndex Property are listed below:

  • Chrome
  • Firefox
  • Internet Explorer
  • Opera
  • Safari

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.