How to scroll to an element inside a div?

I have a scrolled div and I want to have an event when I click on it, it will force this div to scroll to view an element inside.
I wrote its JavasSript like this:

document.getElementById(chr).scrollIntoView(true);

but this scrolls all the page while scrolling the div itself.
How to fix that?

I want to say it like this:
MyContainerDiv.getElementById(chr).scrollIntoView(true);

16 Answers
16

Leave a Comment