-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
42 lines (36 loc) · 1.46 KB
/
main.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
// Variables
const inputFirstColor = document.getElementById("fistColor");
const inputSecndColor = document.getElementById("scendColor");
const first = document.querySelector(".first");
const boddy = document.querySelector("body");
const h = document.querySelectorAll(".h");
//
//console.log(Number(inputFirstColor.value.replace("#", "")));
//if(Number(inputFirstColor.value.replace("#", "")))
//boddy.style.backgroundImage = `linear-gradient(to right, ${inputFirstColor.value},${inputSecndColor.value})`;
inputFirstColor.addEventListener("input", function() {
if (Number(inputFirstColor.value.replace("#", "")) <= 808080) {
for (const n of h) {
n.style.color = "white";
}
} else {
for (const n of h) {
n.style.color = "black";
}
}
boddy.style.backgroundImage = `linear-gradient(to right, ${inputFirstColor.value},${inputSecndColor.value})`;
first.textContent = `${inputFirstColor.value},${inputSecndColor.value}`;
});
inputSecndColor.addEventListener("input", function() {
if (Number(inputSecndColor.value.replace("#", "")) <= 808080) {
for (const n of h) {
n.style.color = "white";
}
} else {
for (const n of h) {
n.style.color = "black";
}
boddy.style.backgroundImage = `linear-gradient(to right, ${inputFirstColor.value},${inputSecndColor.value})`;
first.textContent = `${inputFirstColor.value},${inputSecndColor.value}`;
}
});