diff --git a/script.js b/script.js index 2cf9ed6..11af40e 100644 --- a/script.js +++ b/script.js @@ -14,9 +14,13 @@ function createGrid(size) { let blocks = document.querySelectorAll(".block"); blocks.forEach(block => { - block.addEventListener("mouseover", (event) => {event.target.style.backgroundColor = "#000"}); + block.addEventListener("mouseover", (event) => { + event.target.classList.add("colored") + }); block.addEventListener("mouseout", (event) => { - setTimeout(() => event.target.style.backgroundColor = "#fff", 1 * 1000); + setTimeout(() => { + event.target.classList.remove("colored"); + }, 1 * 1000); }); }) } diff --git a/style.css b/style.css index 8370513..147cae7 100644 --- a/style.css +++ b/style.css @@ -12,4 +12,8 @@ /* padding: 10px; */ flex: 1; aspect-ratio: 1 / 1; +} + +.colored { + background-color: #000; } \ No newline at end of file