-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaCode.js
More file actions
40 lines (35 loc) · 1.1 KB
/
JavaCode.js
File metadata and controls
40 lines (35 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const grid = document.querySelector('#container')
grid.style.display = 'grid';
//grid.style.
makeGrid(16);
function makeGrid(sideSize){
grid.textContent = '';
for(let j = 0; j < sideSize; j++){
for(let i = 0; i < sideSize; i++){
const square = document.createElement('div');
square.style.color = 'purple';
square.style.display = 'grid';
square.style.gridColumn = i + 1;
square.style.gridRow = j + 1;
square.style.minHeight = '10px';
square.style.backgroundColor = 'white';
//square.textContent = i;
//square.style.gridAutoColumns = minmax(10, auto);
grid.appendChild(square);
}
}
}
const dip = document.querySelectorAll('div');
dip.forEach((div) => {
div.addEventListener("mouseover", (e) => {
e.target.style.backgroundColor = 'black';
});
})
const reset = document.querySelector('#recreate');
reset.addEventListener('click', (e) => {
let newSize = prompt("How many per side?");
if(newSize > 100){
newSize = 100;
}
makeGrid(newSize)
})