Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Better way to write this animation?

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #148242
    Rugg
    Participant

    Howdy,

    Below are two variations of an animation I’m working on using jQuery. Both produce the same output, but seem redundant in syntax. I’m curious if anyone could suggest a cleaner approach to writing the animation (if there is).

    One

    $('div').stop().animate({ top: 200 }, 400).animate({ top: 0 }, 400);
    

    Two

    $('div').stop().animate({ top: 200 }, 400, function () {
    
           $(this).animate({ top: 0 }, 400);
    
    }); 
    

    Thank You

Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.