-
Notifications
You must be signed in to change notification settings - Fork 0
/
myscripts.js
61 lines (27 loc) · 1.19 KB
/
myscripts.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
var container = document.getElementById("container");
function hover() {
container.style.transform = "translateY(-6px)";
}
const colorCard = document.querySelectorAll(".colorCards1", ".colorCards2", ".colorCards3", ".colorCards4", ".colorCards5");
const buttonElement = document.getElementById("btn");
document.addEventListener('keydown', e => {
if (e.key === ' ') {
generatePalette();
}
document.getElementById("btn").addEventListener("click", generatePalette);
function generatePalette() {
colorCard.forEach(colorCard => {
const newColor = generatePalette();
});
colorCard.querySelector(".colorCards1", ".colorCards2", ".colorCards3", ".colorCards4", ".colorCards5").style.background = newColor;
colorCard.querySelector("p").innerText = newColor;
}
});
function generatePalette() {
const hexArray = ['0','1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
let color = '#';
for (let i = 0; i < 6; i++) {
color += hexArray[Math.floor(Math.random() * hexArray.length)];
}
return color;
}