Use jQuery to scroll to the end

I have some list items that are displayed when the user clicks the button, the button is at the very bottom of the page, so if the user clicks several times, they are forced to continue scrolling down to see the button.

I want the scroll bar to be the lowest when the user clicks a button.

+3
source share
2 answers

Using jQuery:

$('#foo').click(function() {
  $('html, body').animate({scrollTop: $(document).height()}, 'slow');
  return false;
});
+4
source

You do not need to use jQuery for this:

window.scroll(0, document.documentElement.offsetHeight);
+3
source

Source: https://habr.com/ru/post/1781942/


All Articles