DOM Event
Add Event(์ด๋ฒคํธ ๋ฑ๋ก): addEventListener
๋์ ๊ธฐ๋ฅ(์ฌ์ฉ์ ์ ๋ ฅ ๋ฑ) ์ถ๊ฐ
Event Capturing(์ด๋ฒํธ ์บก์ฒ๋ง)
Capture In
์ด๋ฒคํธ๊ฐ ๋ฐ์ํ์ ๋ ํ์ ์์๋ก ์ด๋ฒคํธ ์ ๋ฌ
Document
>HTML
>body
>div
>button
(event target)addEventListener
์capture:true
์ต์ ์ถ๊ฐ
Event Bubbling(์ด๋ฒํธ ๋ฒ๋ธ๋ง)
Bubble Out
์ด๋ฒคํธ๊ฐ ๋ฐ์ํ์ ๋ ์์ ์์๋ก ์ด๋ฒคํธ ์ ๋ฌ
button
(event target) >div
>body
>HTML
>Document
stopPropagation
์ด๋ฒคํธ ์ ๋ฌ ๋ฐฉ์ง
option: once
ํ๋ฒ๋ง ์คํํ๊ณ ์ ๊ฑฐ
addEventListener
์once:true
์ต์ ์ถ๊ฐ
Remove Event(์ด๋ฒคํธ ์ ๊ฑฐ): removeEventListener
ํ ๋น๋ ์ด๋ฒคํธ ์ ๊ฑฐ
Event Delegation(์ด๋ฒคํธ ์์)
์ด๋ฒคํธ ์บก์ฒ๋ง๊ณผ ๋ฒ๋ธ๋ง ํ์ฉํ์ฌ ์ด๋ฒคํธ ์์ ๊ตฌํ
์์๋ง๋ค ์ด๋ฒคํธ ํธ๋ค๋ฌ๋ฅผ ํ ๋นํ์ง ์๊ณ , ์์ ์์์์ ํ์ ์์์ ์ด๋ฒคํธ ์ ์ด
Reference
Last updated