HTMLElement: accessKeyLabel-Eigenschaft
Die schreibgeschützte HTMLElement.accessKeyLabel
-Eigenschaft gibt einen String zurück, der den vom Browser zugewiesenen Zugriffsschlüssel des Elements enthält (falls vorhanden); andernfalls wird ein leerer String zurückgegeben.
Beispiel
JavaScript
js
const btn = document.getElementById("btn1");
const shortcutLabel = btn.accessKeyLabel || btn.accessKey;
btn.title += ` [${shortcutLabel.toUpperCase()}]`;
btn.onclick = () => {
const feedback = document.createElement("output");
feedback.textContent = "Pressed!";
btn.insertAdjacentElement("afterend", feedback);
};
HTML
html
<button accesskey="h" title="Caption" id="btn1">Hover me</button>
Ergebnis
Spezifikationen
Specification |
---|
HTML # dom-accesskeylabel |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
accessKeyLabel |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Siehe auch
HTMLElement.accessKey
- Das globale accesskey Attribut.