I have a div that has a large number of items in it. I select these items dynamically by clicking a button, overflow is auto in my case. What I want is that when an item that is
You can use the scrollTop property of HTMLElement to set the amount its content is scrolled by.
And you can get the amount you need to scroll by from offsetTop of the element to which you want to scroll.
For example with this HTML:
foo
bar
baz
You could use this JavaScript to scroll the container div to third paragraph:
document.getElementById("container").scrollTop = document.getElementById("item-3").offsetTop;