-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDOM.js
More file actions
37 lines (29 loc) ยท 1.31 KB
/
DOM.js
File metadata and controls
37 lines (29 loc) ยท 1.31 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
/* -- // $ [javascript.info] ์์ ๊ฒ์ํ๊ธฐ
ํ
์ด๋ธ๊ณผ ํผ์ด ์๋ ๋ฌธ์๊ฐ ์๋ค๊ณ ๊ฐ์ ํฉ์๋ค.
์๋ ์กฐ๊ฑด์ ๋ง๋ ์์๋ ์ด๋ป๊ฒ ์ฐพ์ ์ ์์๊น์?
id="age-table"์ธ ํ
์ด๋ธ
ํ
์ด๋ธ ๋ด์ label ์์ ๋ชจ๋(์ด 3๊ฐ)
ํ
์ด๋ธ ๋ด์ ์ฒซ ๋ฒ์งธ td(Age๊ฐ ์ ํ ๊ณณ)
name="search"์ธ form
ํผ์ ์ฒซ ๋ฒ์งธ input
ํผ์ ๋ง์ง๋ง input
๋ณ๋์ ์ฐฝ์์ table.html์ ์ด์ด ๋ธ๋ผ์ฐ์ ๋ด ๋๊ตฌ๋ฅผ ์ฌ์ฉํด ๋ฌธ์ ๋ฅผ ํ์ด๋ณด์ธ์. (https://ko.javascript.info/task/find-elements/table.html)
------------------------------------------------------- */
// ^ 1. id="age-table"์ธ ํ
์ด๋ธ
document.querySelector('#age-table');
// ^ 2. ํ
์ด๋ธ ๋ด์ label ์์ ๋ชจ๋(์ด 3๊ฐ)
// table.getElementsByTagName('label')
document.querySelectorAll('#age-list label'); // NodeList(3)ย [label, label, label]
// ^ 3. ํ
์ด๋ธ ๋ด์ ์ฒซ ๋ฒ์งธ td(Age๊ฐ ์ ํ ๊ณณ)
// table.rows[0].cells[0]
// table.getElementsByTagName('td')[0]
document.querySelector('td');
table.querySelector('td');
// ^ 4. name="search"์ธ form
// let form = document.getElementsByName('search')[0]
document.querySelector('form[name="search"]');
// ^ 5. ํผ์ ์ฒซ ๋ฒ์งธ input
document.querySelector('input');
// ^ 6. ํผ์ ๋ง์ง๋ง input
let inputs = document.querySelectorAll('input');
inputs[inputs.length-1];