0

I need to do scrolling with JS. I know it can be done on the window with window.scrollBy or window.scrollTo, but I haven't been able to find how to get it done inside of an element that has the overflow-y: scroll css property. Here's a JSBin as an example of what I want to scroll: http://jsbin.com/UcUQul/1/edit

1 Answer 1

1

You can use scrollTop property. For instance:

var outer = document.getElementById('outer');
outer.scrollTop = 10; 

See this JSFiddle for an example.

Sign up to request clarification or add additional context in comments.

2 Comments

I don't want to scroll on the window, I want to scroll inside the div.
@tzenderman - "window" is just a name of the <div> you've used in your code. See this JSFiddle for an example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.