js_DOM_02_nodes(부모/자식/형제)

AMJ·2023년 7월 3일
0

javaScript_log

목록 보기
2/3

참고 :


List Type

  • nodeList : 선언된 그대로 적용.
  • htmlCollection : 자동으로 변경 상태 반영.

자식

const test = document.getElementById('color');
test.childNodes; // nodeList type;
test.children; // collection type; // 일반적인 요소들

// 주로 사용됨
test.firstElementChild;
test.lastElementChild;

childNodes

  • text, comment와 같은 요소 포함.

형제

const t2 = document.getElementById('xxx');

t2.previousElementSibling; // xxx 이전 형제
t2.nextElementSibling; // xxx 이후 형제

profile
재미있는 것들

0개의 댓글