I'm trying to focus the scroll based on the selected add class, when I click on the previous and next scroll buttons, I need to focus it. how can i do this please check my fiddle https://jsfiddle.net/kannankds/bcszkqLu/
<ul class="kds"> <li>tile dtls1</li> <li>tile dtls2</li> <li>tile dtls3</li> </ul> <input type="button" value="previous" class="previous"> <input type="button" value="next" class="next">
Add
$(".kds").scrollTop(($(".currentSelection").index()-2) * $(".currentSelection").outerHeight());
for previous and
previous
$(".kds").scrollTop($(".currentSelection").index() * $(".currentSelection").outerHeight());
for next
next
UPDATED FIDDLE
You can animate your scroll using scrollTop , for example:
scrollTop
$('.kds').animate({'scrollTop' : (current.index()) * 30},1000);
Here 30, because whether your height + top + top of the bottom.
Working script
Source: https://habr.com/ru/post/1242771/More articles:Getting value from a returned promise from an asynchronous function - javascriptFuture task deviates from ThreadPoolExecutor - javaAntenna custom container (hexagonal) with adapter - javaAFNetworking IP Availability in Fast - Always Consistent with General Reachability? - iosError compiling iOS application with openCV framework on real device - iosReact Native Android Splash Screen - javaAndroid fragments must be static - javaRxJS and AngularJS HTTP - how can I achieve this? - httpAngular Material Selection Affects Fixed Blocks - javascriptLazy loading elements in ngRepeat collection in AngularJS - javascriptAll Articles