HTMLElement: accessKeyLabel プロパティ
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
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> |
ブラウザーの互換性
関連情報
HTMLElement.accessKey- accesskey グローバル属性