trippincat trippincat - 1 month ago 5
Javascript Question

scroll to element in horizontal div

I have a horizontal div:

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>

Answer

$.scrollTo is your friend:

$(container).scrollTo(target)