Getting and changing a window scroll in JavaScript
The following properties contain how much the window is scrolled:
javascriptlet t = document.documentElement.scrollTop; // from top
let l = document.documentElement.scrollLeft; // from left
These properties can be changed to scroll the window to an arbitrary position:
javascriptdocument.documentElement.scrollTop = 200;
Задание 1
By clicking on the button, scroll
the window to the position 300px
from the top.
Задание 2
By clicking on the button, scroll
the window to the position 100px
from the bottom.
Задание 3
On button click, scroll the window to the very top.
Задание 4
On button click, scroll the window to the very bottom.