Hey friends.Could you help me out with an icon.I am trying to have my weather icon switched if i have different weather conditions.
var apiIcon="https://cdn.glitch.com/6e8889e5-7a72-48f0-a061-863548450de5%2F10n.png?1499366021399" + icon+ ".png"; $('#currentTemp').prepend('<img src='+ apiIcon+'>');
to this one liner:
$('#currentTemp').prepend('<img src='+ icon +'>');
wow.Thank you so much.You saved me a lot of time.you are genius!!!
FYI - I was looking at the rest of your code and found something that is probably not working the way you think it will. I have a question at the bottom of this message regarding a couple of pieces (shown below). I hope you don’t mind unsolicited feedback for something you may still be working on, but I wanted you to be aware of a potential problem you may experience with the current code.
var id = data.weather.id, bgIndex, backgroundId=[299,499,599,699,799,800]; backgroundId.push(id); bgIndex=backgroundId.sort().indexOf(id); // console.log(backgroundId); $('body').css('background-image','url('+backgroundImg[bgIndex]+')');
Earlier in the code you have:
backgroundImg =[ 'https://positively.com/files/THUNDERSTORM_Featured.jpg', 'https://i.ytimg.com/vi/LbAigABOm_E/maxresdefault.jpg', 'http://cdn.abclocal.go.com/content/wtvd/images/cms/automation/images/511280_1280x720.jpg', 'http://cdn.images.express.co.uk/img/dynamic/153/590x/secondary/uk-snow-478595.jpg', 'https://www.quotemaster.org/images/af/afe2d12019c50287052148c0f00f1c84.jpg', 'https://cn.pling.com/img//hive/content-pre1/54633-1.jpg', 'http://www.airninja.com/pictures/great-ocean-road/beach-sky.jpg',]
My question is if another id besides the ones in backgroundId comes back from the API call, why do you think your current code with the use of sort and indexOf is going to be able to tell you the index of an image that you do not currently have in your backgroundImg array?