반응형

app.js:4 Uncaught TypeError: Cannot set properties of null (setting 'innerText')
    at app.js:4

에러발생 

 

 

innerText의 어떤 속성이 'null' 상태 임을 알려주고있다. 

 

여기서 헤멤 ,

const title = document.querySelector(".hello h1");

console.log(title);

app.js 에는 이렇게 적혀있는 상태. 

 

title === html의 element

document

querySelector === array 형태로 css 셀렉터처럼 사용할 수 있음, 간편하고 유용한 함수. 

class,id 전부 사용가능하며, class id를 앞에 쓰고 스페이스바 한번 띈다음에 해당 태그를 쓰면, 호출됨.

동일한 class가 있을 경우 1st element만 리턴함.

-> 해당하는 모든 태그를 호출하기 원하면 "querySelectorAll"함수를 사용한다.

".hello h1"

console.log(title);

 

 

 

 

'Developer' 카테고리의 다른 글

Events  (0) 2021.12.28
serching for element 2  (0) 2021.12.28
HTML in JavaScript (정말*100중요)  (0) 2021.12.28
The document object  (0) 2021.12.28
Contiditonals part Three..  (0) 2021.12.27

+ Recent posts