简体   繁体   中英

Move scrollable contents relatively with jQuery

I have a container with scrollable contents, and I need to move the position of the scroll relatively to its current position, say 20 pixels downwards. I'd like to use ScrollTo plugin, alternatively the scrollTop() jQuery function.

So if I run the desired command again and again, the container scroll is supposed to continue moving until reaching the end. Pseudo-code:

$(myContainer).scrollTo( { delta: '+20px' } );

scrollTop should do it:

$('#myContainer').scrollTop($('#myContainer').scrollTop() + delta);

try it on jsfiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM