분류 전체보기 (49) 리스트형 addEventListener 자바스크립트에서 이벤트를 처리하는 방법중 하나인 addEventListener 메서드를 사용하여 이벤트 핸들러를 등록할 수 있다. EventTarget.addEventListener('eventType', Function, [options]) 'eventType'에는 대표적인 마우스이벤트로는 'click', 'mousemove', 'mouseover'등이 있다. Function에는 보통 콜백함수가 들어간다. document.addEventListener('click', coordinate); function coordinate(event) {console.log(`client: ${event.clientX}, ${event.clientY}`)}; 화면을 클릭하면 coordinate 함수가 실행되고 콘솔창.. 이전 1 ··· 4 5 6 7 다음