I am using Ajax to load the content of a div element. I have a call back function that I want to use to scroll to the appropriate element, after the data has been loaded.
I also have the id of the element I want to scroll to.

Most of the documentation I have seen talk about the widnow.scrollTo() function.

Does anyone know how to get this to work within a div with a vertical scrollbar.

Got this to work.
Step 1. Get the offsetTop amount of the element you want to scroll to.
Step 2. Set this equal to the scrollTop size of the container, in my case a div.

document.getElementById('id').scrollTop = document.getElementById('id').offsetTop;

Got this to work.
Step 1. Get the offsetTop amount of the element you want to scroll to.
Step 2. Set this equal to the scrollTop size of the container, in my case a div.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.