scroll to div code example
Example 1: smooth scroll jquery onclick
$("#button").click(function() {
$('html, body').animate({
scrollTop: $("#myDiv").offset().top
}, 2000);
});
Example 2: javascript go to div id
//slowScroll
function scroll() {
$('html, body').animate({
scrollTop: $("#divName").offset().top
}, 2000)};
window.onload = scroll;
Example 3: scroll to specific div
$(window).scroll(function() {
$('html, body').animate({
scrollTop: $("#myDiv").offset().top
}, 2000);
});