I want that when the user clicks one button, he scrolls +10 pixels down. I can't use $('html, body').animate({scrollTop: '10px'}, 300); here, because it will just scroll +10px from the top and that's not what I need. Is it possible to do what I want? Thanks.
$('html, body').animate({scrollTop: ($(window).scrollTop() + 10) + 'px'}, 300);
The scrollTop() jQuery function not only scrolls the page, but also returns the current scroll position.
To get the current scroll position, use var y = $('body').scrollTop(); then use that to calculate the number you need (y+10).
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