redrom
redrom

Reputation: 11642

Javascript : How to scroll horizontally to given position within an overflowed div?

I have following situation

WRAPPER (100% width of page)
----------------------------------------------
|                                            |  
|                                            |
|     CONTENT (8000px width)                 |  
|                                            |  
|                                            |
----------------------------------------------
|     HORIZONTAL SLIDER FOR CONTENT          |
----------------------------------------------

Dragging the slider is moving thought the content.

I would like to ask how can i programatically trigger horizontal slider click to move for give position. Or how move to the given position on axis X.

I tried scrollTo but without the luck (it works only for document object.

Maybe use the anchors, but i would like the simplest solution.

Many thanks for any advice.

Upvotes: 0

Views: 40

Answers (2)

Maxim Palenov
Maxim Palenov

Reputation: 720

You can use jquery scrollLeft() method (or scrollLeft DOM property) on the container

Upvotes: 0

Vijay Mishra
Vijay Mishra

Reputation: 350

Did you try with scrollLeft(value)?

For more information on this please see the link https://api.jquery.com/scrollleft/

Upvotes: 1

Related Questions