blob: e2e275dba352d188e0a09df554b54e5181e6e42a (
plain)
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
|
---
title: ShadowRoot.activeElement
slug: Web/API/ShadowRoot/activeElement
tags:
- API
- プロパティ
- リファレンス
- ShadowRoot
- ウェブコンポーネント
- シャドウ DOM
browser-compat: api.ShadowRoot.activeElement
translation_of: Web/API/ShadowRoot/activeElement
---
{{APIRef("Shadow DOM")}}
**`activeElement`** は {{domxref("ShadowRoot")}} インターフェイスの読み取り専用プロパティで、シャドウツリー内でフォーカスを持っている要素を返します。
## 構文
```js
shadowRoot.activeElement
```
### 値
現在フォーカスを持っている {{domxref('Element')}}、またはフォーカスを持っている要素がなければ `null` です。
## 例
```js
let customElem = document.querySelector('my-shadow-dom-element');
let shadow = customElem.shadowRoot;
let focusedElem = shadow.activeElement;
```
## 仕様書
{{Specifications}}
## ブラウザーの互換性
{{Compat}}
## 関連情報
- {{domxref("Document.activeElement")}}
|