Search code examples
javascriptjqueryscroll

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>

Solution

  • $.scrollTo is your friend:

    $(container).scrollTo(target)