본문 바로가기
  • Build Up Routine
Basic/노마드코더

노마드코더__바닐라 JS로 크롭웹만들기 수업노트 #2 - 자바스크립트로 HTML가져오기.

by 까느.dev 2022. 3. 31.

 

 getElementsByClassName() : 많은 element를 가져올때 씀(array를 반환)

-getElementsByTagName() : name을 할당할 수 있음(array를 반환)

-querySelector(“div.hello.h1”) : element를 CSS selector방식으로 검색할 수 있다. 첫번째의 element를 return해줌

⇒ hello란 class 내부에 있는 h1을 가지고 올 수 있다(id도 가능함)

-querySelectorAll(“div.hello.h1”) : 모든 element를 가져 온다.

⇒ h1이 들어있는 array를 가져다 줌

 

 

 

댓글