## /*#3.3-3.4 Events
:element ๋ฅผ ์ฐพ์์ event listener ์ถ๊ฐ*/
//click event:addEventListener:("click",function)
const title = document.querySelector("div.hello:first-child h1");
function handleTitleClick(){
console.log("title was clicked");
}
title.addEventListener("click",handleTitleClick);
//("click",handleTitleClick()): ์ด๋ ๊ฒ ํ๋ฉด ๋ฐ๋ก ์คํ๋๊ธฐ ๋๋ฌธ์ ์๋ฐ์คํฌ๋ฆฝ๊ฐ ํด๋ฆญ์ ํด๋น ํจ์๋ฅผ ์คํํ๋๋ก ()์ ์ธํ๊ณ ์์ฑ.
### //mouseenter
function handleMouseEnter(){
console.log("mouse is here");
}
title.addEventListener("mouseenter", handleMouseEnter);
### //mouseleave
function handleMouseLeave(){
title.innerText = "mouse is gone"; }
title.addEventListener("mouseenter", handleMouseLeave);
## /*#3.5 More window*/
### //window.resize
function handleWindowResize(){
document.body.style.backgroundColor = "tomato";
}
window.addEventListener("resize", handleWindowResize);
### //copy
function handleWindowCopy(){
alert("copier!");
}
window.addEventListener("copy", handleWindowCopy);
### //offline,online
function handleWifiOffline(){
alert("offline!");
}
window.addEventListener("offline", handleWifiOffline);
function handleWifiOnline(){
alert("online!");
}
window.addEventListener("online", handleWifiOnline);