view raw
duy khanh duy khanh - 10 months ago 26
jQuery Question

How to know when the weather is rain or snow or sun?

first i'm sorry because my Eng too bad. I have a question, how i know is it rain or snow ? i try check by temp but its not right . I take data form openweathermap API .
here is my codepen:
and condition to check:

$("#icon").html('<i class="fa fa-sun-o fa-fw fa-5x fa-spin" aria-hidden="true"></i>');
else if(fTemp>58){
$("#icon").html('<i class="fa fa-tint fa-fw fa-5x" aria-hidden="true"></i>');
else if(fTemp>40){
$('#icon').html('<i class="fa fa-cloud fa-5x fa-fw" aria-hidden="true"></i>');


This is the API doc that i found in openweather API

"weather":[{"id":804,"main":"clouds","description":"overcast clouds","icon":"04n"}],

you can get the weather from[0].main

here is how i get that

$.getJSON(',uk&appid=356c0e149219f8d18d30e05f4e1a130f', function(response){

the output will be "Rain" right now