-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
33 lines (29 loc) · 1.12 KB
/
index.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
const getMain = document.getElementById("myMain");
const getMainChildren = getMain.children;
const getOne = document.getElementById("one");
let playerChoose = 0;
getMain.addEventListener("click", (e) => {
let targetElement = e.target;
playerChoose++;
let correctstargets = getMain.contains(targetElement);
if (correctstargets) {
if (playerChoose % 2 === 1) {
targetElement.style.backgroundImage =
"linear-gradient(rgba(38, 28, 72, 5),rgba(38, 28, 72, 5))";
let newChildren = Array.from(getMainChildren);
for (let index = 0; index < newChildren.length; index++) {
if (newChildren[index] == targetElement) newChildren.splice(index, 1);
}
console.log("this", newChildren);
let randomValue = Math.round(
Math.random() * (newChildren.length - 0) + 0
);
newChildren[randomValue].style.backgroundImage =
"linear-gradient( rgba(5, 40, 28, 0.5),rgba(5, 40, 28, 0.5))";
}
} else {
console.log("not marked");
}
});
// "linear-gradient(rgba(38, 28, 72, 5),rgba(38, 28, 72, 5))";
// "linear-gradient( rgba(5, 40, 28, 0.5),rgba(5, 40, 28, 0.5))";