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

1

6 Answers 6

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.

Sign up to request clarification or add additional context in comments.

Comments

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>

Comments

0

Give the following code to scroll to bottom of page.

container.animate({ scrollTop: $(document).height() }, 0);

Comments

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!

Comments

0

you can use :

$('html').animate({ scrollTop: $(document).height() }, 1000);

Comments

0
$(document).ready(function() {

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

});

Simply use this code part.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.