Web HTMLElement API | Element accessKeyLabel property

In Web API there are elements which have accesskey attribute. To fetch this accesskey attribute we use HTMLElement.accessKeyLabel property, which returns a String assigned to the accesskey attribute of the element.

Syntax:

label = element.accessKeyLabel

Note: If the accesskey attribute value is not provided then it returns an empty String.



Example: Height attribute set to 300

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
  
    <style>
        a:focus {
            background-color: magenta;
        }
    </style>
    <script type="text/javascript">
        function getaccesskey() {
            var label = document.getElementById('btn');
  
            document.getElementById(
              'access').innerHTML = 
              label.accessKeyLabel;
        }
    </script>
  
</head>
  
<body>
    <center>
  
        <h1 style="color:green;">  
                GeeksForGeeks  
            </h1>
  
        <h2>HTML Element accessKeyLabel property</h2>
        <button accesskey="g"
                onclick="getaccesskey();"
                id="btn">
          Get accessKeyLabel
      </button>
        <p id='access'></p>
    </center>
</body>
  
</html>

chevron_right


Output:

Click the button:

When the button is clicked:

Supported Browsers:

  • Firefox 8


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 :

Be the First to upvote.


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