Block color now in class instead of modifying inline style
This commit is contained in:
parent
7c9c46779f
commit
265efa765a
|
@ -14,9 +14,13 @@ function createGrid(size) {
|
||||||
|
|
||||||
let blocks = document.querySelectorAll(".block");
|
let blocks = document.querySelectorAll(".block");
|
||||||
blocks.forEach(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) => {
|
block.addEventListener("mouseout", (event) => {
|
||||||
setTimeout(() => event.target.style.backgroundColor = "#fff", 1 * 1000);
|
setTimeout(() => {
|
||||||
|
event.target.classList.remove("colored");
|
||||||
|
}, 1 * 1000);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue