본문 바로가기
TIL/TIL

Adding Event Handler

by koreashowme 2020. 2. 14.

Event: 어떠한 동작의 발생을 전달하기 위해 객체가 메세지를 보낸다. 

ex) 

웹페이지의 로드

버튼의 클릭

브라우저 창의 Resize

 

Dom을 이용해 이벤트 핸들러를 추가할 수 있음. 

onEventName (onClick)

 

console.dir 은 엘리먼트를 확인 할 수 있는 방법 => 객체를 보여준다.

 

A  => li class="comment hello world" id="test  

A className => comment hello world  

A classList => [comment, hello, world] 유사배열

A classList[0] => comment

 

A classList contains('comment') => true

A attributes => class, id 나눠서 보여준다.

comment