I am trying to load a still image into the variable topicImage and then switch to the animated GIF when clicked. My code causes the image to disappear when clicked instead of switching to the animated GIF. Any input would be greatly appreciated.
var topicImage = $("<img>");
topicImage.attr("src", results[i].images.fixed_height_still.url);
topicImage.on( "click", function() {
topicImage.attr("src", results[i].images.fixed_height.url);
});
gifDiv.prepend(p);
gifDiv.prepend(topicImage);
$("#addedGifs").prepend(gifDiv);
}
});
console.log(searchParam);
});