0

As I'm sure you're about to see for yourself, I'm relatively new at coding. I've been struggling to get the png image from json file to show up on my codepen. I've already tried several suggestions I found in my Stackoverflow searches but nothing I've tried seems to work for my situation.

Here's the link to my codepen: http://codepen.io/mbabaian/pen/MpjbZv

The code I'm trying to use to get the image at this time is:

    var currentIcon = wd.current.condition.icon;
         // weather icon settings
  $("#current-icon").html("<img src='wd.current.condition.icon' alt='weather icon'/> ");

And here's the particular json data where the image is located:

https://api.apixu.com/v1/current.json?key=68629a769f564f9bb6450153170703&q=auto:ip

Please let me know if you need any additional information from me about this. Thanks in advance.

2 Answers2

2

Simply use

$("#current-icon").html("<img src='"+wd.current.condition.icon+"' alt='weather icon'/> ");

Here is your updated codepen

Weedoze
  • 13,683
  • 1
  • 33
  • 63
1

You create currentIcon, use it

$("#current-icon").html('<img src="'+currentIcon+'" alt="weather icon"/>');
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Insou
  • 1,303
  • 1
  • 13
  • 17