accessKeyLabel

HTMLElement.accessKeyLabel 只读属性返回一个 String 表示这个元素分配的访问密钥 (如果有的话); 否则返回一个空字符串。

语法

label = element.accessKeyLabel

示例

JavaScript

js
var node = document.getElementById("btn1");
if (node.accessKeyLabel) {
  node.title += " [" + node.accessKeyLabel + "]";
} else {
  node.title += " [" + node.accessKey + "]";
}

node.onclick = function () {
  var p = document.createElement("p");
  p.textContent = "Clicked!";
  node.parentNode.appendChild(p);
};

HTML

html
<button accesskey="h" title="Caption" id="btn1">Hover me</button>

结果

规范

Specification
HTML
# dom-accesskeylabel

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
accessKeyLabel

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

参见