简体   繁体   中英

How can i scroll page to bottom with JS?

How can i scroll page to bottom with JS ? I have problem about it. I need to scroll page to bottom until the load ends. When the page scrolled bottom, pages creates new elements so need to scroll one more time , one more time ... How can i automate it ?

You can use element.scrollIntoView() in order to scroll directly to the element that you want, here is an example you can use

 element.scrollIntoView({ behavior: 'smooth', block: 'start' });
 this.stopScroll();

here is a link for documentation: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView

尝试使用此代码滚动底部

$("html, body").animate({ scrollTop: $(document).height() }, 1000);

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