js returns to the top and always keeps the bottom

Three parts are used:
document.documentElement.scrollHeight //represents the total height of the page, including
undisplayed document.documentElement.clientHeight //represents the visible page height of the page
document.documentElement.scrollTop //represents the current page scroll height

Back to top:

document.body.scrollTop = document.documentElement.scrollTop = 0

Always keep the bottom:

      document.documentElement.scrollTop =
        document.documentElement.scrollHeight -
        document.documentElement.clientHeight

Guess you like

Origin blog.csdn.net/qq_42535651/article/details/104214039