Weather Application background image change help needed

Hi All,
I am working on Weather App for long time still struck with background image change as per the weather condition.

this is the link for of the application please help me how should i go from here to get the background image as per weather conditions.

Thanks& regards,

Simplest method of changing the background image is to implement a switch statement.

yes but how to match with the condition code.
if any snip code please pass to me.


I wrote you if statement because it may be easier to understand that way, but in this case its better to use switch.

  $("body").css('background-image', 'url("../images/PartlyCloudyImageHere")');

weatherCondition should be variable of your weather description, you maybe already have that sorry i don't have enough time to fully check your code.


I have updated the code using switch statement for background images still the background is not updating.

Please have look in my code suggest whats wrong, it been ages i am doing this project.

add var wdsc = ""
to your variables at beginning of the file.
Now in your getJSON function i added this

   switch (wdsc) {
     case "Partly cloudy":
       $("body").css("background-color", "blue");
and it changed background color.
Just add more cases to switch and instead of color you add your images. Happy Coding!
1 Like