<aside> 💡

페이지에 특정 동작이나 상태 변화가 발생 했을 때 브라우저가 발생시키는 신호!

</aside>

문법


  1. addEventListenr 사용하기

    const target = document.querySelector('.box')
    target.addEventListener(이벤트종류, 실행할 함수)
    
  2. onclick 사용하기

    const hello = () => {alert('안녕')}
    
    <button onclick="hello()">안녕</button>
    

이벤트 종류


  1. 마우스 이벤트
이벤트 설명
click 클릭 했을 때
dbclick 더블 클릭했을 때
mousemove 마우스 움직일 때
mouseleave 마우스 나갈 때
  1. 폼 이벤트
이벤트 설명
input 입력될 때
change 값이 변경 할때
focus 포커스 받을 때 ( input 클릭 할 때)

이벤트 객체