php – View a GIF from the top



I have a page that contains a div where the content is loaded by JQuery and a hidden div ( hidden ), with a GIF:

<div id="lista"></div>

<div id="loading" hidden>
    <img src="loading.gif"/>

On this page, I have an "Refresh" button (working perfectly), which calls a JQuery method, and performs the steps:

  1. When run to refresh the list, it hides the list div and displays the div with the gif.
  2. Having the return, do the reverse process.

It simply displays the GIF while waiting for the "list" to be processed and returned (extremely common) .

The problem"

The GIF has "beginning/middle/end" . Let's suppose it displays "1 2 3 4 5 6 7 8 9 10" in a 10 second interval.

Sometimes I hit the "Refresh" button and it doesn't start from the beginning, but wherever it is at that moment (since it's there, but the div is just hidden).


I would like to know, if there is a way to "see the GIF" at the beginning, that is, whenever it is displayed, it starts again .

I don't know if that would have to reload it again, or how to do it.


Another solution would be for you to leave the "src" of the gif blank or null, and when you run your "Refresh", the "src" is fixed, along with the visibility or display style attributes.

There are also solutions like libgif-js and x-gif for you to control how gifs are executed.

Scroll to Top