このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

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

ブラウザーの互換性

関連情報