The HTML ButtonElement.accessKey property is used to return a DOMString which is a single character representing the accessKey in the given button.
Syntax:
ButtonElement.accessKey
Return Value: This property returns a DOMString which is a single character representing the accessKey to the given button.
Example 1:
HTML
< h1 style = "color:green" >neveropen</ h1 > < h2 >HTMLButtonElement.accessKey property</ h2 > < button accessKey = 'g' onclick = "gfg()" > Click </ button > < p id = "gfg" ></ p > < script type = "text/javascript" > function gfg() { var a = document.getElementsByTagName("button"); document.getElementById("gfg").innerHTML = 'accessKey is : '+a[0].accessKey; } </ script > |
Output:
Example 2:
HTML
< h1 style = "color:green" >neveropen</ h1 > < h2 >HTMLButtonElement.accessKey property</ h2 > < button accessKey = 'k' onclick = "gfg()" > Click </ button > < script > function gfg() { var a = document.getElementsByTagName("button"); document.write('accessKey is : ', a[0].accessKey); } </ script > |
Output:
Web API ButtonElement.accessKey Property
Supported Browsers:
- Google Chrome
- Internet Explorer
- Firefox
- Safari
- Opera
- Edge
Reference: https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!