Scroll down to the end of the div

Asked

Viewed 35 times

0

I have the code

1 - $("#fluxo-msg").load('fluxo-mensagem.php', {fake:fake, user:user});
2 -
3 - $('html, body').animate({
4 -    scrollTop: $("#vemaqui").offset().top
5 - }, 1000);

In the line 1 i upload a file that contains the content the user will view

In the line 3,4,5 me trying make sure that after you load the page, it goes down to the div #vemaqui. The problem is that it loads the file, but the scroll does not descend to the div #vemaqui (that is inside the content that will be loaded by the function load()). To div #msg flow that is responsible for receiving the content has a limit of height** de **300px** e como o conteúdo é grande, eu coloquei umoverflow: auto` then after passing the 300px it generates a scroll.

  • Alisson, I think your problem here is identical to the question I put here . In the background you have to run this code synchronously with ajax, which is by nature asynchronous. So that code has to be inside the callback of the load to only run when the contents have loaded and not before as it happens now.

  • 1

    Actually +/- similar to your other question which I answered also: http://answall.com/a/28973/129

  • 1

    @Sergio Verdade. Thank you very much!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.