Scroll to the Bottom and Top of a page with jQuery
This Javascript code will scroll the page bottom
$('html, body').animate({scrollTop:$(document).height()},'fast');
and change your speed as required in numerical or slow , fast. Here we use fast in example
And create jQuery function
$(document).ready(function() {
$('#yourId').click(function(){
$('html, body').animate({scrollTop:$(document).height()}, 'fast');
return false; });
});
And for body part
Use a link to an anchor tag e.g.<div id="<a href="#yourId"> oryourId">
(Complete Code)
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> <script type="text/javascript"> function bottomScroll() { $('html, body').animate({scrollTop:$(document).height()}, 'fast'); } function topScroll() { $('html, body').animate({scrollTop:0}, 'fast'); } </script>
Put this code in Header part:-
<a href="javascript:bottomScroll()">Bottom Scroll</a> <a href="javascript:topScroll()">Top Scroll</a>