I've written a function that empties a div and inserts a random image from unsplash.com every six seconds using the setInterval function in jQuery. I would like to smooth out the transition using the fadeIn and fadeOut functions, but have been unable to successfully implement this. Below is my code:
function playImageSlideshow() {
$("#image-slideshow").removeClass("display-none");
$("#images").append("<img src = 'https://source.unsplash.com/" + currentCity + "'>");
setInterval(function() {
var date = new Date();
$("#images").empty();
$("#images").append("<img src = 'https://source.unsplash.com/" + currentCity + "/?" + date.getTime() + "'>");
}, 6000);
}