| title | HTMLElement: accessKeyLabel プロパティ | ||
|---|---|---|---|
| short-title | accessKeyLabel | ||
| slug | Web/API/HTMLElement/accessKeyLabel | ||
| l10n |
|
{{ APIRef("HTML DOM") }}
HTMLElement.accessKeyLabel は読み取り専用プロパティで、要素に割り当てられたアクセスキーを(あれば)文字列で返します。それ以外の場合は空文字列を返します。
label = element.accessKeyLabel
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);
};<button accesskey="h" title="キャプション" id="btn1">
マウスを当ててください
</button>{{ EmbedLiveSample('Example') }}
{{Specifications}}
{{Compat}}
- {{domxref("HTMLElement.accessKey")}}
- accesskey グローバル属性