How to Scroll Down - JQuery

后端 未结 6 552
慢半拍i
慢半拍i 2020-12-05 18:37

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?



        
相关标签:
6条回答
  • 2020-12-05 18:59

    Try This:

    window.scrollBy(0,180); // horizontal and vertical scroll increments
    
    0 讨论(0)
  • 2020-12-05 18:59

    If you want to scroll down to the div (id="div1"). Then you can use this code.

     $('html, body').animate({
         scrollTop: $("#div1").offset().top
     }, 1500);
    
    0 讨论(0)
  • 2020-12-05 19:13
        jQuery(function ($) {
            $('li#linkss').find('a').on('click', function (e) {
                var
                    link_href = $(this).attr('href')
                    , $linkElem = $(link_href)
                    , $linkElem_scroll = $linkElem.get(0) && $linkElem.position().top - 115;
                $('html, body')
                    .animate({
                        scrollTop: $linkElem_scroll
                    }, 'slow');
                e.preventDefault();
            });
        });
    
    0 讨论(0)
  • 2020-12-05 19:14
    $('.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
    });
    
    0 讨论(0)
  • 2020-12-05 19:15

    This can be used in to solve this problem

    <div id='scrol'></div> 
    

    in javascript use this

    jQuery("div#scrol").scrollTop(jQuery("div#scrol")[0].scrollHeight);
    
    0 讨论(0)
  • 2020-12-05 19:16

    I mostly use following code to scroll down

    $('html, body').animate({ scrollTop:  $(SELECTOR).offset().top - 50 }, 'slow');
    
    0 讨论(0)
提交回复
热议问题