This code works perfectly when there are no conditions:
$("body").css("background-image","url('https://images3.alphacoders.com/892/89289.jpg')");
But, when i try to compare the variable currentWeather with other value it falls apart:
if (currentWeather>0) {
$("body").css("background-image","url('https://images3.alphacoders.com/892/89289.jpg')");
}
The currentWeather
is a variable that holds the degrees value from $.getJSON:
$.getJSON(temperature, function(parse) {
// variable currentWeather contains the degrees value
currentWeather = parse.main.temp.toFixed(1);
temperIndex.innerHTML = currentWeather;
var isRaining = parse.weather.main;
})
The full code on codepen : http://codepen.io/RycerzPegaza/pen/pbzdgY
How to access the value of currentWeather in that if statement so the background change?