blob: 88043995e06e2105826e131a0d6c80e199e025fe (
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
47
48
49
50
51
52
53
54
|
---
title: CustomEvent.detail
slug: Web/API/CustomEvent/detail
tags:
- Property
- Reference
- Read-only
browser-compat: api.CustomEvent.detail
translation_of: Web/API/CustomEvent/detail
---
{{APIRef("DOM")}}
{{domxref("CustomEvent")}} 인터페이스의 **`detail`** 읽기 전용 속성은 이벤트를 초기화할 때 제공한 데이터를 반환합니다.
## 값
이벤트를 초기화할 때 제공한 아무 데이터.
## 예제
```js
// CustomEvent 생성
const catFound = new CustomEvent('animalfound', {
detail: {
name: 'cat'
}
});
const dogFound = new CustomEvent('animalfound', {
detail: {
name: 'dog'
}
});
// 적합한 이벤트 수신기 부착
obj.addEventListener('animalfound', (e) => console.log(e.detail.name));
// 이벤트 발송
obj.dispatchEvent(catFound);
obj.dispatchEvent(dogFound);
// 콘솔에 "cat"과 "dog"가 기록됨
```
## 명세
{{Specifications}}
## 브라우저 호환성
{{Compat}}
## 같이 보기
- {{domxref("CustomEvent")}}
|