G
G
gcj2018-02-08 13:00:15
JavaScript
gcj, 2018-02-08 13:00:15

How to set scroll to footer?

Hello everyone, the following code snippet smoothly moves us to the top on click:

$('.scrollup').click(function(){
      $("html, body").animate({ scrollTop: 0 }, 600);
      return false;
  });


Question: how to do the same, but before the footer. Those. on click, we should smoothly move to the very bottom of the page.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
gcj, 2018-02-08
@gcj

Here is the solution:
$('.scrolldown, .scrollup').on('click', function(event) {
event.preventDefault();
var sc = $(this).attr("href"),
dn = $( sc).offset().top;
$('html, body').animate({scrollTop: dn}, 600);
});

D
Dmitry Kuznetsov, 2018-02-08
@dima9595

The same, almost, only for the #footer (or whatever you want to call it) scroll animation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question