-

document 객체

Patti Smith 2021. 12. 12.

dom 객체를 접근하는 경로의 시작점

html 문서 로드 전 document 객체 먼저 생성하여 dom 트리 생성

 

접근

window.document / document로 접근

document객체 != dom객체 (;스타일 시트 없음)

 

 

가능하면 script 태그 내에 놓는 것이 좋음.

document.style이 아니라 document.body임

 

여태까지 id로 찾았음

tag이름은 여러개가 있을 수 있으니 elements임

- 태그 이름으로 찾기

 

-class 속성으로 찾기

 

 

document.write() 

 

페이지 로딩 과정

브라우저는 html 로드를 하기 전에 텅 빈 document 생성함

브라우저는 html 페이지를 위에서 아래로 해석함

html 태그들을 document객체에 담음(dom객체 생성)

</html>을 만나면 document 객체를 완성하고 닫음.

 

document.wirte()

html 태그들이 dom객체로 대응되고 그게 dom트리에 추가

삽입되 html 태그가 브라우저 화면에 출력

 

document.writeln()

한줄 띄우는 효과

 

document.open()

현재 브라우저에 출력된 html콘텐츠 다 지우고 새로운 html페이지 시작

document담긴 dom트리 지움

 

document.close()

현재 출력된 html 

 

'-' 카테고리의 다른 글

[C언어] 조합  (0) 2022.04.02
7일간 진행했던 교내 해커톤 후기  (0) 2022.03.05
파일 입출력  (0) 2021.11.30
c언어 구조체 고급  (0) 2021.11.22
구조체  (0) 2021.11.16

댓글