March 11, 2012

Jumping to Position on page after Dynamic content added

Question by Cookiimonstar

I use ajax to dynamically add content to my site but i want the page to jump to the content has been added but i cant get i to work.

here is the link i am using to add the content and to jump the the position.

<a href="javascript:ajaxpage('/console/new_message_profile.php', 'message_area');" onclick="window.scrollTo(0, 2000);">

Answer by Starx

Give an id to the dynamically generated element and then

$("#idofdynamicelement")[0].scrollIntoView( true );
// O to make sure its the first item if multiple found
// true to indicate the top position

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!