-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
28 lines (25 loc) · 949 Bytes
/
Copy pathscript.js
File metadata and controls
28 lines (25 loc) · 949 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
const buttons = document.querySelectorAll('.button')
// console.log(buttons)
const body = document.querySelector('body');
buttons.forEach( (button) => {
button.addEventListener('click' , (e) =>{
const color = e.currentTarget.id
body.style.backgroundColor = color;
if (color === 'black' || color==="maroon" || color==="purple") {
body.style.color = 'white';
button.style.border = "2px solid white";
} else {
body.style.color = 'black';
}
})
button.addEventListener('mouseover' , (e) =>{
const color = e.currentTarget.id
body.style.backgroundColor = color;
if (color === 'black' || color==="maroon" || color==="purple") {
body.style.color = 'white';
button.style.border = "2px solid white";
} else {
body.style.color = 'black';
}
})
})