auto animated scroll down using jQuery
30,623
Solution 1
I think you need to calculate body height and pass that to the scrollTop parameter in the animate
$('body,html').animate({ scrollTop: $('body').height() }, 800);
[Check here the working demo] // Link has stopped working
Solution 2
$('#back-bottom a').click(function () {
$('body,html').animate({ scrollTop: $('body').height() }, 500);
return false;
});
i think it will work for you
Author by
user1656139
Updated on January 25, 2020Comments
-
user1656139 over 4 years
I am trying to make an animated scroll to a bottom button using jQuery that fades out when the page is located at the bottom. I have found this code on the internet and modified it, but I could not get it work.
<script> //to bottom $(document).ready(function(){ // hide #back-top first $("#back-bottom").show(); // fade in #back-top $(function () { $(window).scroll(function () { if ($(this).scrollTop() 1) { $('#back-bottom').hide(); } else { $('#back-bottom').show(); } }); // scroll body to 0px on click $('#back-bottom a').click(function () { $('body,html').animate({ scrollTop: 0 }, 800); return false; }); }); }); </script>
-
Sibu over 11 yearscan you show your html markup too
-
Asciiom over 11 yearsCreate a fiddle for this please so people can see what's going wrong exactly. It's hard to guess
-
-
user1656139 over 11 yearsThanks I really appreciate it and please do give me that demo link
-
Michael Peterson over 11 yearsShould work for scrolling to the bottom, but there was also an error in the code for showing the button when not at the bottom.
-
user1656139 over 11 yearsthanks soo much it works great howerever 2 problems 1 it does not scroll smooth and 2 it does not fade out please tell me how to achive that thanks
-
Anudeep GI over 11 yearsfirst think u needed is smooth scroll for that 500 increase to 1000 or how much u needed depending upon that
-
Anudeep GI over 11 yearsfor fade out use this code $('#back-bottom a').fadeOut('slow'); (after this code use fade out code $('body,html').animate({ scrollTop: $('body').height() }, 500); )