Scroll to Div
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
<script>
$(document).ready(function (){
$("#click").click(function (){
$('html, body').animate({
scrollTop: $("#div1").offset().top
}, 2000);
});
});
</script>
</head>
<body>
<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>
</body>
</html>
Most Helpful This Week
JavaScript calculate Fahrenheit from Celsius
Highlight and get the details of table row on click using JavaScript
jQuery simple form with name and email validations
jQuery example of scroll to top
jQuery check if an element is visible or hidden
How to current URL, HOST and URL attributes using JavaScript or jQuery?