supersize
supersize

Reputation: 14773

scrollTo a specific div on long scrolling page when page loads

i have a long scrolling page with lots of divs, one below the other. i would like to scroll automatically when you visit (or reload) the site to scroll from top to a specific div near of the bottom. to jump there isnt a problem, but i want the "scroll" effect. ive checked out scrollTo() but i dont get it to work. my first attempt was something like

$(document).ready(function () {
  $.scrollTo('#div5'); });

but it doesnt fire anything. a little bit help needed :) thanks

Upvotes: 0

Views: 419

Answers (1)

dfsq
dfsq

Reputation: 193261

Try this:

$('html, body').animate({
    scrollTop: $('#div5').offset().top
}, 500);

http://jsfiddle.net/nTwLm/2/

Upvotes: 1

Related Questions