Jquery Slide to Top and Bottom of the Page

11 years 5 months ago
Jquery Slide to Top and Bottom of the Page

Pieced together from the internet.  This code should give you that nice slide action to the bottom and top of the page.  Remember to include jquery.

Basically give your link the id "gototop" or "gotobottom"

Example: <a href="#" id="gototop" >Go To Top</a>

<script>
$(document).ready(function() {

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

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

});
</script>

This tech is being used a bit on my new web app ScrollMySite.com. Check it out to automatically scroll any webpage for presentations or embedded iframes.

< Return to Code Listing

Jquery Slide to Top and Bottom of the Page