简体   繁体   中英

Jumping to Position on page after Dynamic content added

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);">

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

It seems that you let the page scroll to its bottom by using window.scrollTo(0, 2000); I have tried your code on my server,and it worked fine . Can you give more details?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM