Weather App Metric/imperial button

Hello Campers!

I’ve completed my local weather app but since I’ve added a new location search button, I’ve noticed my 2 metric/ imperial buttons are not working until I enter a new location and press submit. can’t figure out why :scream:

Any help is very welcome thanks

Hi. I think you put your change function inside new location function. So my advice is take that part and put them inside main function which means after getting first weather data. It should work after that. Much specifiy take that part and add it after getting first data.

$("#imperial").click(function() {
          $("#temp").html(tempF + "°F");
          $("#wind").html("Wind Speed: " + windM + " mi/h");
        $("#metric").click(function() {
          $("#temp").html(tempC + "°C");
          $("#wind").html("Wind Speed: " + windK + " Km/h");

And ofcourse delete those console.log’s if you dont need them. Making code much harder to read.

1 Like

Fantastic @namrox it worked! Thanks so much for your help :dart:

Glad to hear that. Keep going :airplane:

ahhh catch 22 situation, now I have the opposite problem the new city function would work only if click on both imperial and metric buttons first :scream: