Skip to content

Instantly share code, notes, and snippets.

@ngocongcan
Created August 6, 2019 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ngocongcan/4b56d2d93ccea7cf3493fdc935462dc8 to your computer and use it in GitHub Desktop.
Save ngocongcan/4b56d2d93ccea7cf3493fdc935462dc8 to your computer and use it in GitHub Desktop.
<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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment