I'm not a programmer, but I use the code below to scroll the page to the top.
How can I adapt it to make a scroll down?
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> <a class="btnMedio" href="javascript:;"> <img src="http://desmond.imageshack.us/Himg41/scaled.php?server=41&filename=deixeseuemail.png&res=landing"/> </a> <script> $('.btnMedio').click(function(){ $('html, body').animate({scrollTop:1000},'50'); }); </script>
To auto scroll a page from top to bottom we can use scrollTop() and height() method in jquery. In this method pass the document's height in scrollTop method to scroll.
jQuery scroll() MethodThe scroll event occurs when the user scrolls in the specified element. The scroll event works for all scrollable elements and the window object (browser window). The scroll() method triggers the scroll event, or attaches a function to run when a scroll event occurs.
window. scrollTo(0, document. body. scrollHeight);
Of course, you can also click and drag the scroll bar on the side of the page, but that's a slow and imprecise option–especially if you're using a laptop touchpad. No, by far the best way to jump to the top or bottom of a Web page is by tapping your Home or End key, respectively.
$('.btnMedio').click(function(event) { // Preventing default action of the event event.preventDefault(); // Getting the height of the document var n = $(document).height(); $('html, body').animate({ scrollTop: n }, 50); // | | // | --- duration (milliseconds) // ---- distance from the top });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With