-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
26 lines (25 loc) · 966 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
24
25
26
// Distructuring
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'));
case '5':
return (previousBackground === 'background-5' ? false : body.classList.add('background-5'));
default:
break;
}
}