When finished parsing the json into the specified span tags I wanted to automatically hide the imperial tags currentimperial and forecastimperial but when I try to do this use
$('#currentimperial').hide();
$('#forecastimperial').hide();
and view the result in chrome and look in the console I see that instead of
style="display: none; "
they actually have
style="display: inline; "
Here is my whole javascript and html on jsBin http://jsbin.com/efaguv/edit#javascript,html
Thanks for any help I recieve.
I think the problem is that you haven’t allowed for the fact that your ajax call is asynchronous.
A much simplified example of what’s happening:
Because (in your full code) the ajax success callback makes the elements visible (using
.fadeIn()) the end result is that they are visible.Can you instead hide the elements within that ajax success callback?