jQuery using .html & then window.scrollTo

Posted by AnApprentice on Stack Overflow See other posts from Stack Overflow or by AnApprentice
Published on 2011-01-11T23:37:42Z Indexed on 2011/01/11 23:53 UTC
Read the original article Hit count: 199

Filed under:

Hello, I'm doing the following:

First, inject HTML into the page (a lot) which then increases the window scrollbar:

$("#XXXX").html("LOTS OF HTML").show();

Then i want to scroll down to the end of the page:

window.scrollTo(0,$(document).height());

Problem is the page never scrolls down. I did some console.logging and the scrollTo is running before the HTML from the inject html() is run. I tried this in the JS which injects the HTML, I then tried doing the scroll inside the HTML inject but that made no difference.

Any ideas?

© Stack Overflow or respective owner

Related posts about jQuery