Weather Application background image change help needed

Weather Application background image change help needed
0

#1

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,
Manju


#2

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


#3

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

thanks


#4

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.

#5

Hi

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.


#6

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");
       break;
                    }```
and it changed background color.
Just add more cases to switch and instead of color you add your images. Happy Coding!