greeting.js note - 8hal/momonton_study GitHub Wiki
[question greeting_js_01] what is event.target?
- A reference to the object that dispatched the event.
- It is different from
event.currentTarget when the event handler is called during the bubbling or capturing phase of the event.
More things
- ์ด๋ฒคํธ ๋ฒ๋ธ๋ง์ ํน์ ํ๋ฉด ์์์์ ์ด๋ฒคํธ๊ฐ ๋ฐ์ํ์ ๋ ํด๋น ์ด๋ฒคํธ๊ฐ ๋ ์์์ ํ๋ฉด ์์๋ค๋ก ์ ๋ฌ๋์ด ๊ฐ๋ ํน์ฑ์ ์๋ฏธํ๋ค.
- ์ด๋ฒคํธ ์บก์ณ๋ ์ด๋ฒคํธ ๋ฒ๋ธ๋ง๊ณผ ๋ฐ๋ ๋ฐฉํฅ์ผ๋ก ์งํ๋๋ ์ด๋ฒคํธ ์ ํ ๋ฐฉ์์ด๋ค.
- ์ด๋ฒคํธ ์์์ โํ์ ์์์ ๊ฐ๊ฐ ์ด๋ฒคํธ๋ฅผ ๋ถ์ด์ง ์๊ณ ์์ ์์์์ ํ์ ์์์ ์ด๋ฒคํธ๋ค์ ์ ์ดํ๋ ๋ฐฉ์โ์ด๋ค.
// var inputs = document.querySelectorAll('input');
// inputs.forEach(function(input) {
// input.addEventListener('click', function() {
// alert('clicked');
// });
// });
// ํ์ ์์์ addEventListener ๋ฌ๊ธฐ
var itemList = document.querySelector('.itemList');
itemList.addEventListener('click', function(event) {
alert('clicked');
});
// ์ ๋ฆฌ์คํธ ์์ดํ
์ ์ถ๊ฐํ๋ ์ฝ๋
// ...