Okym
Okym

Reputation: 259

Make GIF disappear after getting played once with Javascript?

This question has kinda been answered before however the answer doesn't really work for me since I need my GIF to actually disappear after getting played once since its a GIF of png image that fades away.

I have a function that replaces my image with my gif however the problem that I have is that it keeps on looping but I need it to disappear after getting played once.

function muda_cad () {
            cad1.src='images/cadeado/cadeado-gif.gif'
        }

Upvotes: 0

Views: 512

Answers (1)

Arthur
Arthur

Reputation: 5158

JS doesn't know about git loop, but if you know the time, you can create a delay with SetTimeout:

function muda_cad () {
    cad1.src='images/cadeado/cadeado-gif.gif'
    // Wait 1sec and replace by png
    setTimeout(function() {
        cad1.src='images/cadeado/cadeado-png.png'
    }, 1000) 
}

Upvotes: 1

Related Questions