Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Scroll Down - JQuery

Tags:

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> 
like image 769
user1301037 Avatar asked Sep 29 '12 05:09

user1301037


People also ask

How do you scroll automatically to the bottom of the page using jQuery?

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.

How can use scroll event in jQuery?

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.

How do you scroll down in JavaScript?

window. scrollTo(0, document. body. scrollHeight);

How do you scroll down to the bottom of a page?

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.


1 Answers

$('.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 }); 
like image 78
undefined Avatar answered Oct 03 '22 07:10

undefined