[JavaScript] Node? Elemnet?

๋””๋”ฉยท2022๋…„ 11์›” 10์ผ
0

Today I Learned

๋ชฉ๋ก ๋ณด๊ธฐ
9/12
post-thumbnail

๐Ÿ“ 2022. 11. 10

JavaScript / Node & Elemnet



๐Ÿ“Œ Today I Learned

  • Node
  • Elemnet

๐Ÿ’ฌ Node

DOM ๋ฌธ์„œ๋Š” node์˜ ๊ณ„์ธต ๊ตฌ์กฐ๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ๊ณ  node๋Š” ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ๋‹ค์–‘ํ•œ ์œ ํ˜•์ด ์กด์žฌํ•œ๋‹ค. (์š”์†Œ(element), ํ…์ŠคํŠธ, ์ฃผ์„ ๋“ฑ๋“ฑ...) element๋Š” ์ด๋Ÿฌํ•œ node์˜ ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ์œ ํ˜• ์ค‘ ํ•œ ๊ฐ€์ง€์ด๋‹ค.

์ฆ‰, node๋Š” elemen์˜ ์ƒ์œ„ ๊ฐœ๋…์ธ ๊ฒƒ์ด๋‹ค.
element๋Š” html ๋ฌธ์„œ์—์„œ <div>, <p>, <title>๊ณผ ๊ฐ™์€ ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ž‘์„ฑ๋œ node๋ผ๊ณ  ํ•  ์ˆ˜ ์žˆ๋‹ค.

์˜ˆ์ œ 1

<!DOCTYPE html>
<html>
  <head>
    <title>kakao</title>
  </head>
  <body>
    <!-- Page Body -->
    <h2>cute chunsik</h2>
    <p id="content">cute cat chunsik!</p>
  </body>
</html>
- DOCTYPE: html
- HTML
	ใ„ดHEAD
    	ใ„ดTITLE
        	ใ„ด#text: kakao
    ใ„ดBODY
   	 	ใ„ด#comment: Page Body
   		ใ„ดH2
    		ใ„ด#text: cute chunsik
        ใ„ดP id="content"
        	ใ„ด#text: cute cat chunsik!

์œ„์™€ ๊ฐ™์ด, node๋Š” ํƒœ๊ทธ, ํ…์ŠคํŠธ, ์ฃผ์„ ๋“ฑ์„ ๋ชจ๋‘ ํฌํ•จํ•œ๋‹ค.

๐Ÿ’ฌ Elemnet

element๋Š” node์˜ ํ•œ ์ข…๋ฅ˜๋‹ค.
์ฃผ๋กœ, <p>, <div> ๊ฐ™์€ ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ž‘์„ฑ๋œ ๋…ธ๋“œ๋ฅผ ๋งํ•œ๋‹ค.

์•ž์˜ ์˜ˆ์ œ์—์„œ element๋Š” <html>, <head>, <title>, <body>, <h2>, <p>์ด๋‹ค.

DOM์„ ์กฐ์ž‘ํ•˜๋Š” ๋ฐฉ๋ฒ•์—๋Š” node๋ฅผ ํƒ์ƒ‰ํ•˜๋Š” ๋ฐฉ๋ฒ•๊ณผ element๋ฅผ ํƒ์ƒ‰ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ๋Š”๋ฐ element๋ฅผ ํƒ์ƒ‰ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•˜๋ฉด ์ฃผ์„์ด๋‚˜ ํ…์ŠคํŠธ ๋“ฑ์„ ์ œ์™ธํ•œ element๋งŒ์„ ํƒ์ƒ‰ํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— DOM์„ ์กฐ์ž‘ํ•  ๋•Œ๋Š” ์ฃผ๋กœ element๋ฅผ ํƒ์ƒ‰ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋งŽ์ด ์‚ฌ์šฉํ•œ๋‹ค.

profile
๋ฌด์‚ฌ์™€์š”... ์—ด๊ณตํ–์š”...

0๊ฐœ์˜ ๋Œ“๊ธ€