Raphael Bergeron Raphael Bergeron - 1 year ago 73
jQuery Question

scroll down then up 2 time when page is loaded

hi guys i'm looking for a jquery that would make my page scroll to the bottom of the page the to the top 2 time, so ( down,up,down,up) Thanks !:) I have this already that works but it only do it one time and i dont know how to make it do it twice!

$(document).ready(function() {
$('html, body').animate({
scrollTop: $(document).height() - $(window).height() },
8000, function() {
$(this).animate({ scrollTop: 0 }, 4000);


Answer Source

here you go: DEMO

  var scrollCount=0;
  var scroll=function(direction){
      var scrollTo= (direction==='down') ? $(document).height() - $(window).height() : 0;
      $('html, body').animate({ 
        scrollTop: scrollTo },
        direction=(direction==='down') ? 'up' : 'down';

for some reason the callback on the animation didn't work: Failed Demo

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download