Slowly auto scroll to the bottom of a div
Clash Royale CLAN TAG#URR8PPP
Slowly auto scroll to the bottom of a div
I'm trying to have my div start slowly scrolling down to the bottom of the div but can't seem to get that to work. I can get my div to scroll to the bottom immediately but I want it to take some time. The code for the scrolling I have right now is
<script type="text/javascript">
$(document).ready(function ()
$('#myDiv').animate(
scrollTop: $('#myDiv').get(0).scrollHeight
, "slow");
);
</script>
The code for my div is
<div class="ASIProfile right" style="overflow:auto; height: 160px;" id="myDiv"></div>
1 Answer
1
$(document).ready(function ()
$('html, body').animate(
scrollTop: $('#myDiv').get(0).scrollHeight
, 1500);
);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="ASIProfile right" style="overflow:auto; height: 1600px;" id="myDiv">
div 1 ( auto scroll to bottom smoothly )
</div>
<div class="ASIProfile right" style="overflow:auto; height: 160px;" id="myDaiv">
div 2
</div>
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Have you tried using an integer instead of "slow" to test different scrolling speeds to see if any variations give the desired result?
– brae
Aug 10 at 15:53