Assuming you have a button with the id button, try this example:
$("#button").click(function() {
$([document.documentElement, document.body]).animate({
scrollTop: $("#elementtoScrollToID").offset().top
}, 2000);
});
Used this to solved your problem
https://codepen.io/jvondoom/pen/VvbrdY
Assuming you have a button with the id `button`, try this example:
$("#button").click(function() {
$([document.documentElement, document.body]).animate({
scrollTop: $("#elementtoScrollToID").offset().top
}, 2000);
});
I got the code from the article *[Smoothly scroll to an element without a jQuery plugin][1]*. And I have tested it on the example below.
<!-- begin snippet: js hide: false -->
<!-- language: lang-html -->
<html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script>
$(document).ready(function (){
$("#click").click(function (){
$('html, body').animate({
scrollTop: $("#div1").offset().top
}, 2000);
});
});
</script>
<div id="div1" style="height: 1000px; width 100px">
Test
</div>
<br/>
<div id="div2" style="height: 1000px; width 100px">
Test 2
</div>
<button id="click">Click me</button>
</html>
<!-- end snippet -->
[1]: http://www.abeautifulsite.net/smoothly-scroll-to-an-element-without-a-jquery-plugin-2/