0

I'm trying to get it when the #name div is pressed, the page will scroll to #profile-pic but not having any luck.

$("#name").click(function() {
$('html, body').animate({
    scrollTop: $("#profile-pic").offset().top
}, 2000);
});

http://jsfiddle.net/qv9f7p6u/1/

user2252219
  • 775
  • 2
  • 16
  • 34
  • possible duplicate of [jQuery Scroll To Section of Page](http://stackoverflow.com/questions/15991356/jquery-scroll-to-section-of-page) – Liam Sep 14 '15 at 15:27

1 Answers1

3

Because the scrollable part is a div, not the page. You need to select the div to scroll.

$('#left-panel').animate({ 
epascarello
  • 185,306
  • 18
  • 175
  • 214