-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
32 lines (26 loc) · 894 Bytes
/
Copy pathscript.js
File metadata and controls
32 lines (26 loc) · 894 Bytes
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
const reset = document.getElementById("reset_button")
const change = document.getElementById("change_button")
reset.addEventListener("click", resetGrid)
change.addEventListener("click", changeColor)
function resetGrid() {
for (let i = 1; i <= 9; i++) {
const gridItem = document.getElementById(i)
gridItem.style.backgroundColor = "transparent"
console.log(gridItem)
}
}
function changeColor() {
const blockId = document.getElementById("block_id")
const colorId = document.getElementById("colour_id")
if (!blockId.value) {
alert("Please enter block id")
}
if (!colorId.value) {
alert("Please enter colour id")
}
resetGrid()
const gridItem = document.getElementById(blockId.value)
gridItem.style.backgroundColor = colorId.value
blockId.value = ""
colorId.value = ""
}