[JS] Event and event handlers

이지·2020년 9월 5일
0

Javascript _ pre

목록 보기
6/10
const title= document.querySelector("#title")
function handleresize(){
 console.log("i have been resized")
window.addeventlistner("resize", handlersize); 
// handleresize()하면 바로 호출하는것이고, ()를 빼면 특정 조건 만족하면 함수 호출한다는 의미 

function handleclick(){
 title.style.color="red";
 } 

title.addeventlistner("click", handleclick); 

js는 이벤트에 반응하기 위해 만들어짐 (intercept)

  1. window 가 줄어들면 문구가 호출
  2. title 클릭하면 색깔이 바뀜
profile
이지피지레몬스퀴지🍋

0개의 댓글