Open In App

Web HTMLElement API | Element accessKeyLabel property

Last Updated : 31 Jul, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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




<!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>


Output:

Click the button:

When the button is clicked:

Supported Browsers:

  • Firefox 8


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads