-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathscript.js
More file actions
23 lines (18 loc) · 750 Bytes
/
script.js
File metadata and controls
23 lines (18 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const board = document.querySelector('.board');
const colors = [`#c859e7`, `#59e7d7`, '#e74c3c', '#8e44ad', '#3498db', '#e67e22', '#2ecc71'];
const totalSubBoxes = 500;
const len = colors.length;
for (let i = 0; i < totalSubBoxes; i++) {
const square = document.createElement(`div`);
square.classList.add(`square`);
square.addEventListener('mouseover', () => {
const idx = Math.floor(Math.random() * len);
square.style.background = colors[idx];
square.style.boxShadow = `0 0 2px ${colors[idx]}, 0 0 10x ${colors[idx]}`;
});
square.addEventListener('mouseout', () => {
square.style.background = `black`;
element.style.boxShadow = '0 0 2px white'
});
board.appendChild(square);
}