All :L
Web(Front) - HTML & DOM ๋ณธ๋ฌธ
๋ฐ์ํ
๐ HTML๊ณผ DOM
1๏ธโฃ DOM (Document Object Model)
- HTML๊ณผ XML๋ฌธ์์ ๊ตฌ์กฐ๋ฅผ ์ ์ํ๋ API ์ ๊ณต
- ๋ฌธ์ ์์ ์งํฉ์ ํธ๋ฆฌ ํํ์ ๊ณ์ธต ๊ตฌ์กฐ๋ก HTML ํํ
- ์ฆ, HTML ๋ฌธ์ ๋ด์ฉ์ ์กฐ์ํ ์ ์๋ API๋ก HTML ๊ณ์ธต๊ตฌ์กฐ ํ์์ ๊ฐ์ฒด๋ก ํํ
- ๊ณ์ธต ๊ตฌ์กฐ ์ ์ผ ์์๋ document ๋
ธ๋ ์กด์ฌ
- ์๋์ HTML ํ๊ทธ or ์์(element)๋ฅผ ํํํ๋ ๋ ธ๋ ์กด์ฌ
- ์๋์ ๋ฌธ์์ด์ ํํํ๋ ๋ ธ๋ ์กด์ฌ
- HTML ๋ฌธ์์ ๊ฒ์๊ณผ ์กฐ์(์ถ๊ฐ, ์์ , ์ญ์ ) ๊ฐ๋ฅ
2๏ธโฃ DOM ๋ฌธ์ ๊ณ์ธต ๊ตฌ์กฐ
- Document : HTML or XML ๋ฌธ์ ํํ
- HTMLDocument : HTML ๋ฌธ์์ ์์๋ง ํํ
- HTMLElement ํ์ ํ์ : ๋จ์ผ ์์ or ์์ ์งํฉ์ ์์ฑ์ ํด๋นํ๋ JS ํ๋กํผํฐ ์ ์
- Comment ๋ ธ๋ : HTML or XML์ ์ฃผ์ ํํ
- ๊ณ์ธต ๊ตฌ์กฐ
Node - Document - HTMLDocument - Element - HTMLElement - HTMLHeadElement - HTMLBodyElement - HTMLTitleElement - HTMLParagraphElement - HTMLInputElement - etc ... - Attr - CharacterData - Text - Comment
3๏ธโฃ ๋ฌธ์ ๊ฐ์ฒด ๋ง๋ค๊ธฐ
- text node๋ฅผ ๊ฐ๋ ๊ฐ์ฒด์ ๊ฐ์ง ์๋ ๊ฐ์ฒด๋ก ๋๋จ
- createElement(tagName) : element node ์์ฑ
- createTextNode(text) : text node ์์ฑ
- appendChild(node) : node๋ฅผ child๋ก ์ถ๊ฐ
- ๊ฐ์ฒด์ ์์ฑ ์ค์
- setAttribute(name, value) : ๊ฐ์ฒด ์์ฑ ์ง์
- ์น ๋ธ๋ผ์ฐ์ ๊ฐ ์ง์ํ์ง ์๋ ํ๊ทธ์ ์์ฑ๋ ๊ฐ๋ฅ (์ฆ, ์ฌ์ฉ์ ์ ์ ์์ฑ๋ ์ฌ์ฉ ๊ฐ๋ฅ)
- getAttribute(name) : ๊ฐ์ฒด ์์ฑ๊ฐ ๊ฐ์ ธ์ด
- setAttribute(name, value) : ๊ฐ์ฒด ์์ฑ ์ง์
- innerHTML & innerText
- innerHTML : ๋ฌธ์์ด์ HTML ํ๊ทธ๋ก ์ฝ์
- innerText : ๋ฌธ์์ด์ text node๋ก ์ฝ์
4๏ธโฃ ๋ฌธ์ ๊ฐ์ฒด ๊ฐ์ ธ์ค๊ธฐ
- getElement
- getElementById(id) : id์ ์ผ์นํ๋ element ๊ฐ์ฒด ์ป๊ธฐ
- getElementsByClassName(class-name) : class-name๊ณผ ์ผ์นํ๋ element ๋ฐฐ์ด ์ป๊ธฐ
- getElementsByTagName(tag-name) : tag-name๊ณผ ์ผ์นํ๋ element ๋ฐฐ์ด ์ป๊ธฐ
- getElementsByName(name) : name๊ณผ ์ผ์นํ๋ element ๋ฐฐ์ด ์ป๊ธฐ
- querySelector
- querySelector(selector) : selector์ ์ผ์นํ๋ ์ฒซ ๋ฒ์งธ element ๊ฐ์ฒด ์ป๊ธฐ
- querySelectorAll(selector) : selector์ ์ผ์นํ๋ ๋ชจ๋ element ๋ฐฐ์ด ์ป๊ธฐ
5๏ธโฃ ๋ฌธ์ ๊ฐ์ฒด ์ ๊ฑฐ
- ๊ฐ์ฒด ์ ๊ฑฐ
- removeChild(childnode) : ๊ฐ์ฒด์ ์์ ๋ ธ๋ ์ ๊ฑฐ
๋ฐ์ํ
'STUDY > Front End' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Web(Front) - CSS ์ ํ์ (Selector) (0) | 2024.08.26 |
---|---|
Web(Front) - CSS (0) | 2024.08.26 |
Web(Front) - HTML Semantic (0) | 2024.08.25 |
Web(Front) - HTML ๊ณต๊ฐ ๋ถํ ํ๊ทธ (0) | 2024.08.25 |
Web(Front) - HTML Markup Elements (0) | 2024.08.25 |
Comments