-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Expand file tree
/
Copy pathindex.md
More file actions
58 lines (40 loc) · 1.23 KB
/
index.md
File metadata and controls
58 lines (40 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
title: "HTMLElement: accessKeyLabel プロパティ"
short-title: accessKeyLabel
slug: Web/API/HTMLElement/accessKeyLabel
l10n:
sourceCommit: a3d9f61a8990ba7b53bda9748d1f26a9e9810b18
---
{{ APIRef("HTML DOM") }}
**`HTMLElement.accessKeyLabel`** は読み取り専用プロパティで、要素に割り当てられたアクセスキーを(あれば)文字列で返します。それ以外の場合は空文字列を返します。
## 構文
```js-nolint
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>
```
### 結果
{{ EmbedLiveSample('Example') }}
## 仕様書
{{Specifications}}
## ブラウザーの互換性
{{Compat}}
## 関連情報
- {{domxref("HTMLElement.accessKey")}}
- [accesskey](/ja/docs/Web/HTML/Reference/Global_attributes/accesskey) グローバル属性