accessKeyLabel

您正在阅读此内容的英文版本,因为该语系尚未翻译。 帮助我们翻译此文章吧!

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

语法

label = element.accessKeyLabel

示例

JavaScript

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

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

Result

Specifications

Specification Status Comment
HTML Living Standard
HTMLElement.accessKeyLabel
Living Standard No change from initial definition.
HTML 5.1 Recommendation Removed. pull w3c/html#144issue w3c/html#99WICG discussion.
HTML5
HTMLElement.accessKeyLabel
Recommendation Snapshot of  HTML Living Standard, initial definition.

浏览器兼容

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
accessKeyLabelChrome No support NoEdge No support NoFirefox Full support 8IE ? Opera ? Safari ? WebView Android No support NoChrome Android No support NoFirefox Android Full support 8Opera Android ? Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown

See also