Scroll to the Bottom and Top of a page with jQuery

Sangwan Pankaj Reply 12:12


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="yourId"> or <a href="#yourId"> 
Put this code in Header part:-
(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> 
 



Related Posts

onClick function 1502799855281533121
Copyright by GhostPHP. Powered by Blogger.

Search

Recent Post

Popular Posts

Follow us