Как прокрутить вниз - JQuery - программирование
Подтвердить что ты не робот

Как прокрутить вниз - JQuery

Я не программист, но я использую приведенный ниже код для прокрутки страницы вверх.

Как я могу адаптировать его для прокрутки вниз?

<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>
4b9b3361

Ответ 1

$('.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
});

Ответ 2

Попробуйте следующее:

window.scrollBy(0,180); // horizontal and vertical scroll increments

Ответ 3

Это можно использовать для решения этой проблемы.

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

в javascript используйте это

jQuery("div#scrol").scrollTop(jQuery("div#scrol")[0].scrollHeight);

Ответ 4

В основном я использую следующий код для прокрутки вниз

$('html, body').animate({ scrollTop:  $(SELECTOR).offset().top - 50 }, 'slow');

Ответ 5

    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();
        });
    });

Ответ 6

Если вы хотите прокрутить вниз до div (id = "div1"). Тогда вы можете использовать этот код.

 $('html, body').animate({
     scrollTop: $("#div1").offset().top
 }, 1500);