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
jQuery move multi select values from one to another multi select list
Check if a string ends with the given target string
How to change text after click event using JavaScript?
How to check if an element or HTML tag exists using JavaScript?
How to define Global Variable in JavaScript?
How can I redirect the user from one page to another using jQuery or pure JavaScript?