-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/GDSC-DEU/Web-Basic-Study-23-24
- Loading branch information
Showing
31 changed files
with
454 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
function SetLinkColor(color) { | ||
var alist = document.querySelectorAll("a"); | ||
var size = 0; | ||
while (size < alist.length) { | ||
alist[size].style.color = color; | ||
size = size + 1; | ||
} | ||
} | ||
function SetBodyColor(color) { | ||
document.querySelector("body").style.color = color; | ||
} | ||
function SetBackgroundColor(color) { | ||
document.querySelector("body").style.backgroundColor = color; | ||
} | ||
function nightDayHandler(self) { | ||
if (self.value === "night") { | ||
self.value = "day"; | ||
SetBackgroundColor("black"); | ||
SetBodyColor("white"); | ||
|
||
SetLinkColor("yellow"); | ||
} else { | ||
self.value = "night"; | ||
SetBackgroundColor("white"); | ||
SetBodyColor("black"); | ||
|
||
SetLinkColor("green"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const title = document.querySelector("div.hello:first-child h1"); | ||
|
||
var color = "black"; | ||
|
||
function handleTitleColor() { | ||
if (color == "black") { | ||
title.style.color = "blue"; | ||
color = "blue"; | ||
} else if (color == "blue") { | ||
title.style.color = "black"; | ||
color = "black"; | ||
} | ||
} | ||
|
||
function handleMouseEnter() { | ||
if (title.style.color == "black") { | ||
title.style.color = "yellow"; | ||
} else if (title.style.color == "blue") { | ||
title.style.color = "green"; | ||
} | ||
} | ||
|
||
function handleMouseLeave() { | ||
if (title.style.color == "yellow") { | ||
title.style.color = "black"; | ||
} else if (title.style.color == "green") { | ||
title.style.color = "blue"; | ||
} | ||
} | ||
|
||
title.addEventListener("click", handleTitleColor); | ||
title.addEventListener("mouseenter", handleMouseEnter); | ||
title.addEventListener("mouseleave", handleMouseLeave); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<div class="hello"> | ||
<h1 style="color: black">하이하이</h1> | ||
</div> | ||
<script src="app.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# 20240730 | ||
HTML Document 객체를 통해 자바스크립트에서 Html 객체를 다룰 수 있다. | ||
웹브라우저가 html을 보여주는 객체로 만들어 주어서 javascript로 조작가능 | ||
class와 id등의 정보로 document아래에 있는 html object를 가져온다음 자바스크립트로 하위 속성을 가져오고 설정할 수 있다 | ||
# document 객체에서 html element 불러오기 | ||
```javascript | ||
document.getElementById("id 문자열") // id 값으로 Element 가져오기 | ||
document.getElementsByClassName("class 문자열") // class 값으로 Element 배열 가져오기 | ||
document.getElementsByTagName("태그 이름 문자열") // // class 값으로 Element 배열 가져오기 | ||
``` | ||
|
||
|
||
## 만능 querySelector | ||
```javascript | ||
document.querySelector("CSS 선택자 표기법 문자열") // CSS 선택자로 Element 가져오기. 단, 여러개일 경우 첫번째만! | ||
document.querySelectorAll("CSS 선택자 표기법 문자열") // CSS 선택자로 Element 배열 가져오기 | ||
``` | ||
|
||
|
||
addEventListener와 함수로 이벤트 처리 => 그냥 객체에 함수를 바로 넣어버리면 안되는 것일까? 가능하지만 동작 방식이 약간 다르다. | ||
|
||
객체에 바로 할당 : 여러 번 수행했을 때 마지막 함수로 한다.(덮어쓰기) | ||
addEventListener와 함수로 이벤트 처리 : 이벤트에 대한 함수를 누적한다(여러 함수다 실행된다) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const header = document.querySelector("h1"); | ||
|
||
function headerClickHandler() { | ||
console.log("🍅"); | ||
} | ||
header.onclick = headerClickHandler; | ||
header.onclick = ()=>{ | ||
console.log("Tomato"); | ||
} | ||
header.addEventListener("click",()=>{ | ||
console.log("Tomato"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<h1>🍅</h1> | ||
<script src="app.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const h1 = document.querySelector("div.hello:first-child h1"); | ||
function handleTitleClick() { | ||
console.log("title was clicked"); | ||
h1.style.color = "blue"; | ||
} | ||
|
||
function handleMouseEnter() { | ||
h1.innerText = "mouse is here"; | ||
/*console.log("mouse is here");*/ | ||
} | ||
function handleMouseLeave() { | ||
h1.innerText = "mouse is gone"; | ||
/*console.log("leave is here");*/ | ||
} | ||
function handleWindowResize() { | ||
/*화면 크기가 줄어들면 배경화면 색이 변함*/ | ||
document.body.style.backgroundColor = "tomato"; | ||
} | ||
function handleWindowCopy() { | ||
/*복사할 경우 copier 알림창이 나타남*/ | ||
alert("copier"); | ||
} | ||
function handleWindowOffline() { | ||
/*와이파이 꺼지면 알림창*/ | ||
alert("SOS no wifi"); | ||
} | ||
function handleWindowOnline() { | ||
/*와이파이 연결되면 알림창 */ | ||
alert("wifi"); | ||
} | ||
|
||
h1.addEventListener("click", handleTitleClick); | ||
|
||
h1.addEventListener("mouseenter", handleMouseEnter); | ||
|
||
h1.addEventListener("mouseleave", handleMouseLeave); | ||
|
||
window.addEventListener("resize", handleWindowResize); | ||
|
||
window.addEventListener("copy", handleWindowCopy); | ||
|
||
window.addEventListener("offline", handleWindowOffline); | ||
|
||
window.addEventListener("online", handleWindowOnline); |
Oops, something went wrong.