I have a horizontal div:
i need to scroll to the specific element in this div via JavaScript button (after the click div must be scrolled to that element). How can I do this?
<div class="group" id="frames">
<div class="item frames-item">
<img src="1.jpg">
</div>
<div class="item frames-item">
<img src="2.jpg">
</div>
....
....
</div>
Try below function to make element or li in center on click
This will work in jqgrid as well as div
If you have an element, that has inner horizontal scroll, you can do as followed by my example: Two arrows with classes that are used, will scroll the element to sides.
In this case, I have with class .tabs which I need to move. The 500 is time in miliseconds to animate this scroll, so you can kind of have your own slider..
The code below should do the trick:
Or you could use the following snippet:
Where
position()
returns the#dstElement
's relative position to `.scrollable' if scrollable is positioned.Code & Demo