Home > Net >  jquery - scroll page to bottom
jquery - scroll page to bottom

Time:11-24

I simply want to scroll a page to the bottom
seems - it is a deep secret

$(window).on('load', function(){
    let y = $('body').height();
    console.log(y);  // 2285
    $('document').scrollTop(y);
});

also tried:

$('document').scrollTop(y   'px');  
$('body').scrollTop(y);
$('body').scrollTop(y   'px');

also tried some code from here - without success

please help

CodePudding user response:

Here is the alternative way. It works for me.

<script>
  jQuery(document).ready(function () {
    jQuery("button").click(function () {
      jQuery("html, body").animate(
        {
          scrollTop: jQuery("html, body").get(0).scrollHeight,
        },
        1000
      );
    });
  });
</script>
  • Related