I'm trying to figure out how to get the page automatically scroll to a specific div
when the page has loaded. I have tried using the jQuery scroll function, but can't get it to work correctly.
Any suggestions?
Following is what I have tried so far:
jQuery(function() {
jQuery(window).scrollTop(jQuery('.container').offset().top);
});
You can do this using the .animate()
method:
$(document).ready(function () {
// Handler for .ready() called.
$('html, body').animate({
scrollTop: $('#what').offset().top
}, 'slow');
});
what