Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6644915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:13:23+00:00 2026-05-26T00:13:23+00:00

Is it possible to restart an animated GIF used as background-image ? Consider this

  • 0

Is it possible to restart an animated GIF used as background-image?

Consider this HTML:

<div id="face">
    <div id="eyes"></eyes>
</div>

And this style:

#eyes.blink {
    background-image:url('blink.gif');
}

I would like the blink.gif animation to play every time I add the class blink to #eyes, not just the first time.

I expected this to work:

function startBlink() {
    $('#eyes').addClass('blink');
}

function stopBlink() {
    $('#eyes').removeClass('blink');
}

The problem is that both Firefox and WebKit browser do not play a background-image GIF animation again once it has played once. Adding/removing the class blink only works the first time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:13:24+00:00Added an answer on May 26, 2026 at 12:13 am

    You can get the animated gif to replay by reloading it. This isn’t ideal for bandwidth, especially if your image is large, but it will force a restart of the animation.

    In my example I’m adding and removing it onclick of <div id="animated">:

    $('#animated').click(function() {
    
        /* Reference to the clicked element and toggle the .go class */
        var $div = $(this);
        $div.toggleClass('go');
    
        /* Start the animated gif */
        if ($div.hasClass('go')) {
    
            /* Create an <img> element and give it the animated gif as a src.  To 
               force a reload we add a date parameter to the URL */
            var img = document.createElement('img');
            img.src = "http://yoursite.com/animated.gif?p" + new Date().getTime();
    
            /* Once the image has loaded, set it as the background-image */
            $(img).load(function(){
                $div.css({backgroundImage: "url("+img.src+")"});
            });
    
        /* Remove the background-image */        
        } else {
           $div.css({backgroundImage: "none"});
        }
    })
    

    Demo of it in action.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to re-write this query to restart numbering when the UName changes
is it possible to restart Tomcat6 by executing a JSP? This because I would
is this possible to load dynamically struts action class without having to restart? I
Is it possible to do something like this in unix? monit restart | pause
I know that it is not possible to restart a used Java Thread object,
Is it possible to restart IIS7 using C#? If so, how?
Possible Duplicate: Eclipse wont start after computer restart Lately I opened my eclipse and
Possible Duplicate: Any way to “reboot” the JVM? Is there any option to restart
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: Can main function call itself in C++? I found this problem very

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.