I have images I photoshopped that are weather icons like a sun, cloud, rainy cloud, etc. On the Site I want to be able to click on them, and change the background image of the site, the Body background. But it doesn’t work, can’t click on the image, nothing happens. This is what I have so far, with #skyclear being the image ID, and clearsky being the css styling =>
$('body').addClass(bodyClass);
$('#skyclear').on('click', () => {
bodyClass = 'clearsky'
})
2
Answers
This should be in the onClick function. You should also consider removing any unnecessary classes inside of the onClick as well.
I would just do it like this: