-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
23 lines (22 loc) · 851 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const { body } = document;
function changeBackground(number) {
//Check if background already showing
let previousBackground;
if (body.className) {
previousBackground = body.className;
}
// Reset CSS class for body
body.className = '';
switch (number) {
case '1':
return (previousBackground === 'background-1' ? false : body.classList.add('background-1'));
case '2':
return (previousBackground === 'background-2' ? false : body.classList.add('background-2'));
case '3':
return (previousBackground === 'background-3' ? false : body.classList.add('background-3'));
case '4':
return (previousBackground === 'background-4' ? false : body.classList.add('background-4'));
default:
break;
}
}