0

Actually i am using following code to scroll on top

 var container = $('#items_suggession_right'), scrollTo = $(".selected");
         container.animate({scrollTop: scrollTo.offset().top - container.offset().top +
                       container.scrollTop()}, 0); 

But i cant able to Scroll set In Bottom. Please Help me to Set Bottom Scroll using jquery

  • 4
    Possible duplicate of [jQuery Scroll to bottom of page/iframe](https://stackoverflow.com/questions/1890995/jquery-scroll-to-bottom-of-page-iframe) – fen1x Dec 28 '17 at 06:51

6 Answers6

1

You can use

var time = 0; // in milliseconds
$("html, body").animate({ scrollTop: $(document).height() }, time);.

You can increase the time value to provide smoother and animated scroll to bottom.

Ankit Agarwal
  • 30,378
  • 5
  • 37
  • 62
0

Give the following code to scroll to bottom of page.

container.animate({ scrollTop: $(document).height() }, 0);
kmg
  • 499
  • 3
  • 16
0
$(document).on("click","#bottom",function() {
  var window_height = $(window).height();
    var document_height = $(document).height();
    $('html,body').animate({ scrollTop: window_height + document_height },1000);
});

Hope it helps!

kvorobiev
  • 5,012
  • 4
  • 29
  • 35
0
$(document).ready(function() {

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

});

Simply use this code part.

Gayashan Perera
  • 661
  • 7
  • 12
  • Welcome to Stack Overflow! Although this code may help to solve the problem, it doesn't explain why and/or how it answers the question. Providing this additional context would significantly improve its long-term educational value. Please edit your answer to add explanation, including what limitations and assumptions apply. – рüффп Dec 28 '17 at 09:40
0

you can use :

$('html').animate({ scrollTop: $(document).height() }, 1000);
Mahesh Sharma
  • 73
  • 1
  • 5
0

jsfiddle code updated for scroll to bottom

 $(document).ready(function() {
    $('html,body').animate({
          scrollTop: $('.testwrap').height()
      }, 800);
  });
.testwrap{
  width: 500px;
  height: 1000px;
  border: 2px dotted #c00;

}
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">           </script>


</head>
<body>
  <div class="testwrap"></div>
</body>
</html>