Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
181
rated 0 times [  188] [ 7]  / answers: 1 / hits: 26228  / 10 Years ago, sat, may 24, 2014, 12:00:00

I have a JS to make a smooth scroll from the bottom of the page to the top with this and it works:



<script>

$(a[href='#top']).click(function() {
$(html, body).animate({ scrollTop: 0 }, slow);
return true;
});
</script>


But now I want to make a smooth scroll from the top to the bottom, I tried it with this:



 <script>

$(a[href='#footer']).click(function() {
$(html, body).animate({ scrollToBottom: 0 }, slow);
return true;
});
</script>`


It doesn't work, it's not a smooth scroll. Does anyone know what's wrong with this?


More From » jquery

 Answers
8

There is no such thing as scrollToBottom. Try this:



$(html, body).animate({ scrollTop: document.body.scrollHeight }, slow);

[#70863] Thursday, May 22, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
daytonm

Total Points: 519
Total Questions: 83
Total Answers: 89

Location: Saudi Arabia
Member since Mon, Sep 5, 2022
2 Years ago
;