일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- matplotlib
- pandas
- 다나와
- Agile
- webcrawling
- Scrum
- TypeScript
- 크롤링
- keras
- ECS
- DANAWA
- 자바스크립트
- 프로젝트
- tensorflow
- data analyze
- Method
- opencv
- javascript
- angular
- instance
- Project
- data
- Crawling
- visualizing
- algorithm
- analyzing
- python
- 애자일
- adaptive life cycle
- AWS
Archives
- Today
- Total
LiJell's 성장기
Events 본문
반응형
const title = document.querySelector("div.hello:first-child h1");
function handleTitleClick() {
title.style.color = "blue";
console.log("title was clicked!");
}
title.addEventListener("click", handleTitleClick);
- 클릭하면
추가해보기
- browser console에서 변화를 확인해보세요!
- 다양한 이벤트를 링크를 통해 확인해보세요
const h1 = document.querySelector("div.hello:first-child h1");
// properties를 찾을 땐 console.dir 를 이용하고 browser console에서 확인하는 방법이 좋음
function handleTitleClick() {
h1.style.color = "blue";
console.log("title was clicked!");
}
function handleMouseEnter() {
h1.innerText = "Mouse is here!";
}
function handleMouseLeave() {
h1.innerText = "Mouse is gone!";
}
function handleWindowResize() {
document.body.style.backgroundColor = "tomato";
}
function handleWindowCopy() {
alert("copier!");
}
function handleWindowOffline(){
alert("SOS no WIFI");
}
function handleWindowOnline(){
alert("WIFI is On")
}
h1.onclick = handleTitleClick;
// event listener을 사용하면 나중에 remove하기 편함 .removeEventListener
h1.addEventListener("mouseenter", handleMouseEnter);
h1.addEventListener("mouseleave", handleMouseLeave);
window.addEventListener("resize", handleWindowResize);
window.addEventListener("copy", handleWindowCopy);
window.addEventListener("offline", handleWindowOffline);
window.addEventListener("online", handleWindowOnline);
반응형
'Front-End > JavaScript' 카테고리의 다른 글
Events Control (0) | 2022.05.18 |
---|---|
Conditional (0) | 2022.05.18 |
Function (0) | 2022.05.17 |
Data Type (0) | 2022.05.17 |
Booleans (0) | 2022.05.13 |
Comments