일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- data analyze
- matplotlib
- ECS
- 다나와
- TypeScript
- javascript
- Crawling
- 애자일
- DANAWA
- keras
- Scrum
- adaptive life cycle
- pandas
- analyzing
- 자바스크립트
- data
- python
- Agile
- 프로젝트
- AWS
- webcrawling
- Method
- opencv
- angular
- algorithm
- tensorflow
- visualizing
- 크롤링
- instance
- Project
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