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

  • Home
  • SEARCH
  • 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 6638797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:28:45+00:00 2026-05-25T23:28:45+00:00

I need a hand making this code below working. I’ve had it working so

  • 0

I need a hand making this code below working. I’ve had it working so that when the user hovers over the image it animates up, then down when losing focus, but now I want it to run on window load on an infinite loop.

$(document).ready(function(){
    $(window).load(function(){
        $('.navImage').animate({top:'-=13'}, 700)
    }, function(){
        $('.navImage').animate({top:'+=13'}, 700);
    });
});

At the moment it’s only animating 13pixels up, not down, and obviously the animation doesn’t currently loop. Do I need to use some sort of callback?

Any help would be great, thanks.

[EDIT] Removed the height:toggle, didn’t mean to include that.

  • 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-25T23:28:45+00:00Added an answer on May 25, 2026 at 11:28 pm

    Try this:

    function moveUp() {
        $('.navImage').animate({top:'-=13', height:'toggle'}, 700, moveDown);
    }
    
    function moveDown() {
        $('.navImage').animate({top:'+=13'}, 700, moveUp);
    }
    
    $(document).ready(function(){
        $(window).load(moveUp);
    });
    

    === UPDATE 1 ===

    function move(jElem, bUp) {
        jElem.animate(
            {top: (bUp ? '-' : '+') + '=13'},
            700,
            function() {
                move(jElem, !bUp);
            }
        );
    }
    
    $(document).ready(function() {
        $(window).load(function() {
            $('.navImage').each(function() {
                move($(this), true);
            });
        });
    });
    

    Also see my jsfiddle.

    === UPDATE 2 ===

    Now they start with random delay:

    function move(jElem, bUp) {
        jElem.animate(
            {top: (bUp ? '-' : '+') + '=13'},
            700,
            function() {
                move(jElem, !bUp);
            }
        );
    }
    
    $(document).ready(function() {
        $('.navImage').each(function(iIndex, jElem) {
            // get random delay
            var iTime = Math.floor(Math.random() * 700);
            setTimeout(
                function() {
                    move($(jElem), true);
                },
                iTime
            );
        });
    });
    

    Also see my jsfiddle 2.

    === Update 3 ===

    And in this jsfiddle additional with random speed: jsfiddle 3.

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

Sidebar

Related Questions

I need a quick hand figuring out what this code is doing, and how
I have following array, that I need to operate by hand on bitmaps. const
Hay i need to hand implemeneting a voting system into a model. I've had
I need to generate a custom button through code, this is how i am
I need some help making a linq query that will select a list of
I am probably making this more complicated than it need be and hope you
Need a hand/guide of creating a view that handles a list of parameters which
I am stuck and in need of a hand. Hope someone can help? Anyone
I need to get the left hand side integer value from a decimal or
Need a function that takes a character as a parameter and returns true if

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.