I want to create an image and then have a gif play after it, repeating indefinitely. When I link to this GIF it loops just fine in my browser. However, when I toggle its display with show()/hide():
var pics = $('.slider');
function autoSlideIn() {
if (index > pics.length - 1) {
index = 0;
}
$(pics[index]).show();
setTimeout("autoSlideOut()", duration);
}
function autoSlideOut() {
if (index > pics.length - 1) {
index = 0;
}
$(pics[index]).hide();
index++;
autoSlideIn();
}
<img class="slider" src="www.image.com/picture.png"/>
<img class="slider" src="www.gifdontwork.com/gif.gif"/>
Instead, the GIF will play only once and then be stuck on a single frame and never restart despite it repeating normally. How can I restart it without reloading the image?