Swapping images using jQuery in sequence
<p>I'm trying to use jQuery to swap the background image of an element in set sequence to create an animation where each image is a different frame and it should iterate through the frames until it reaches the last frame and then return to the beginning again.</p>

<p>My code is as follows:</p>

<pre><code>$spinner_currentFrame = 1;

            function UpdateSpinner(target, numFrames)
            {
                $spinner_currentFrame = ($spinner_currentFrame) + 1;
                if($spinner_currentFrame &gt; numFrames) {
                    $spinner_currentFrame = 1;
                }
                $(target).css("background-image", "frame-" + $spinner_currentFrame + ".jpg");
            }

            $(document).ready(function()
            {
                $spinner_loadingAnim = setInterval(function ()
                {
                    UpdateSpinner('#spinner', 300);
                },
                24);
            });
</code></pre>

<p>The reason I'm not using a sprite is because I have a few hundred images and the frames have been exported from Flash like <code>frame-1.jpg, frame-2.jpg</code>. However my code isn't reporting any errors but the background image isn't been added... Any ideas? Suggestions?</p>

<p>Thanks</p>
