![](https://velog.velcdn.com/images/jiwoni1/post/c200e8eb-aa83-46b2-84b5-46a98f16926b/image.png)
backgroundColor
JS code
document.body.style.backgroundColor = ''
예시
const switcherTag = document.querySelector('.switcher')
const gray = document.querySelector('#grayButton')
const white = document.querySelector('#whiteButton')
const navy = document.querySelector('#navyButton')
const switchColor = function (event) {
if (event.target === gray) {
document.body.style.backgroundColor = 'gray'
document.body.style.color = 'white'
} else if (event.target === white) {
document.body.style.backgroundColor = 'white'
document.body.style.color = 'black'
} else if (event.target === navy) {
document.body.style.backgroundColor = 'navy'
document.body.style.color = 'white'
}
}
switcherTag.addEventListener('click', switchColor)
backgroundImage
JS code
document.body.style.backgroundImage = url(images.jpg)
lodash를 활용하여 backgroundImage가 랜덤으로 나오게
const pictures = _.range(1, 7)
const number = _.sample(pictures)
document.body.style.backgroundImage = `url(images/${number}.jpg)`