[HTML] Node

Gomao·2023년 3월 8일
0

Web programming

목록 보기
1/16

Node는 HTML DOM에서 정보를 저장하는 계층적 단위이다.

노드의 종류

  1. document node(문서 노드)
  2. element node(요소 노드) - 유일하게 속성 노드를 가질 수 있음.
  3. comment node(주석 노드)
  4. attribute node(속성 노드)
  5. text node(텍스트 노드)

노드의 값
=> nodeName, nodeValue, nodeType등을 통해 접근 가능함.

document.childNodes[index] : 문서의 index번째 자식 노드
var node1 = document.childNodes[index]

node1.childNodes[index] : node1의 index번째 자식 노드
var node2 = node1.childNodes[index]

document.childNodes[0].nodeName : 문서의 첫번째 자식 노드의 이름
document.getElementById("heading").firstChild.nodeValue; 
                  : Id가 "heading"인 요소의 첫번째 자식 노드의 값

이후에 추가로 알게된 사실을 계속해서 업로드 할것

profile
코딩꿈나무 고마오

0개의 댓글