HTMLElement: accessKeyLabel プロパティ
HTMLElement.accessKeyLabel
は読み取り専用プロパティで、要素に割り当てられたアクセスキーを(あれば)文字列で返します。それ以外の場合は空文字列を返します。
構文
js
label = element.accessKeyLabel
例
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="キャプション" id="btn1">
マウスを当ててください
</button>
結果
仕様書
Specification |
---|
HTML # dom-accesskeylabel |
ブラウザーの互換性
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.
関連情報
HTMLElement.accessKey
- accesskey グローバル属性