From 715b482d18f75d6d1c9657a053370c0e061ecac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=9D=80=EC=A7=84?= <149948792+eunjingjing@users.noreply.github.com> Date: Tue, 30 Jul 2024 18:40:49 +0900 Subject: [PATCH] modernJS 1st Week --- eunjin/modernJS/app.js | 33 +++++++++++++++++++++++++++++++++ eunjin/modernJS/index.html | 14 ++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 eunjin/modernJS/app.js create mode 100644 eunjin/modernJS/index.html diff --git a/eunjin/modernJS/app.js b/eunjin/modernJS/app.js new file mode 100644 index 0000000..bea3465 --- /dev/null +++ b/eunjin/modernJS/app.js @@ -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); diff --git a/eunjin/modernJS/index.html b/eunjin/modernJS/index.html new file mode 100644 index 0000000..7fa381a --- /dev/null +++ b/eunjin/modernJS/index.html @@ -0,0 +1,14 @@ + + +
+ + +