Reputation: 782
I am using the window.scrollTo();
method on a button click. But, when I click the button, it just jumps to the position. I want it to physically display the scrolling to the position of the window. How can I do this?
Upvotes: 2
Views: 702
Reputation: 1269
Jquery is the best answer for this. It makes it really simple
$('html, body').animate({
scrollTop: $(".the_div_you_want_to_got_to").offset().top
}, 1750);
If you have not used Jquery before, it is a javascript extension. You will need to include it in the head of your doc
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Upvotes: 1