JS + DOM

김지환·2020년 5월 2일
0

Front-end

목록 보기
6/15

Event 함수

Event

요소.addEventListener(이벤트종류,function(){
이벤트 일어났을때 실행할 내용;
});
->이렇게 인자로 전달된 함수를 콜백함수라고 한다.

이벤트 종류

click / contextmenu / dbclick / mousedown / mouseenter/
mouseleave / mousemove / mouseover / mouseout /
mouseup / pointerlockchange / pointerlockerror /
select / wheel

DOM(document object model)

JS와 html을 연결해주는 것이 DOM이다.

웹페이지의 html을 계층화 시켜 트리구조로 만든 객체 모델이다.

window 는 전역객체이며 그 안에 객체 형태인 document 가있다.
그리고 document안에 html을 가지고 있다.
Javascript에서 html을 객체 형태로 가지고 있는 모델을 document라고 하며 window.document와 document 둘다 가능하다.

document 객체는 DOM 트리의 root node에 접근하게 해주는데,

이런식으로 내용을 다 바꿔준다.

profile
Web Developer

0개의 댓글