$(window).scroll(function() { $('html, body').animate({ scrollTop: $("#myDiv").offset().top }, 2000); });