Change grid size with slider

This commit is contained in:
lolabird 2023-11-09 20:15:53 -07:00
commit 012f0b29e5
3 changed files with 24 additions and 4 deletions

View file

@ -4,6 +4,8 @@ const container = document.querySelector(".container");
const conWidth = container.clientWidth;
const conHeight = container.clientHeight
const grid = document.createElement("div");
const gridSlider = document.querySelector("#gridSlider");
function createGrid() {
const gridArea = numGrid ** 2;
@ -24,13 +26,22 @@ function createGrid() {
item.addEventListener("mouseover", colorGrid);
});
gridSlider.addEventListener("change", getGridDimensions);
}
function getGridDimensions() {
numGrid = gridSlider.value;
while (container.firstChild) {
container.removeChild(container.lastChild);
}
console.log(numGrid);
createGrid();
}
function colorGrid() {
this.style.background = "blue";
}
createGrid();
createGrid();