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
Add a comment
|
1 Answer
You can use scrollTop property. For instance:
var outer = document.getElementById('outer');
outer.scrollTop = 10;
See this JSFiddle for an example.
2 Comments
tzenderman
I don't want to scroll on the window, I want to scroll inside the div.
kamituel
@tzenderman - "window" is just a name of the
<div> you've used in your code. See this JSFiddle for an example.