How to set scroll to bottom in jquery?

Today now in this blog i will show you how to set scroll to bottom in jquery. i know Sometimes, we need to set a scroll bottom as a default by using jquery, so now in bellow example we can know how we can use scrollHeight for get the total height of a scroll class div also with scroll, and at last here i will use animate with scrollTop attribute and it set bottom, So it is Basically when our page will load then it will automatically scroll as bottom.


<html lang="en">
	<title>Scroll Down bottom</title>
	<script src=""></script>
	<div class="scroll-class" style="border: 1px solid black;height: 200px;overflow: scroll;width: 300px;">
			Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
			tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
			quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
			consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
			cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
			proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    <script type="text/javascript">
	     var objDiv = $(".scroll-class");
    	 var h = objDiv.get(0).scrollHeight;
    	 objDiv.animate({scrollTop: h});

Read Also : How to push item to 0 index or first of $scope object in AngularJS?

Thanks for read. I hope it help you. For more you can follow us on facebook.


About Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Shahriar Sagor →