-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject1.js
More file actions
28 lines (25 loc) · 771 Bytes
/
Project1.js
File metadata and controls
28 lines (25 loc) · 771 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
//color switcher
buttons = document.querySelectorAll('.button');
body = document.querySelector('body');
buttons.forEach(function (button) {
console.log(button);
button.addEventListener('click', function (event) {
console.log(event);
console.log(event.target);
if (event.target.id === 'grey') {
body.style.backgroundColor = event.target.id;
}
if (event.target.id === 'white') {
body.style.backgroundColor = event.target.id;
}
if (event.target.id === 'blue') {
body.style.backgroundColor = event.target.id;
}
if (event.target.id === 'yellow') {
body.style.backgroundColor = event.target.id;
}
if (event.target.id === 'purple') {
body.style.backgroundColor = event.target.id;
}
});
});