문제

okay I know how to smooth scroll to an anchor but how do I smooth scroll a certain static amount (ie. 300px) every time I click a certain object until I reach the end of my page. I can do this once but how bout doing it over and over?

도움이 되었습니까?

해결책

var pixelsToMove = 50;

$('.myButton').click(function () {
    var currentScrollTopValue = $('#container').scrollTop();

    $('#container').scrollTop(currentScrollTopValue + pixelsToMove);

});

https://api.jquery.com/scrollTop/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top