1element.scrollTo(x, y);
2window.scrollTo(x, y);
3element.scrollTo({
4 top: 100,
5 left: 100,
6 behavior: 'smooth'
7});
1scroll function
2
3window.scroll({
4 top: 0,
5 left: 0,
6 behavior: 'smooth'
7});
8
9window.scroll(x-coord, y-coord)
10window.scroll(options)
1//scrolls to horizontal position 500
2 window.scrollTo(500, 0);
3
4 //scrolls to vertical position 500
5 window.scrollTo(0, 500);
6
7// scrolls to bottom of page
8 window.scrollTo(0, document.body.scrollHeight);
1const scrollToTop = () => {
2 document.getElementById("scroller").scroll(0,0)
3}
4
5<button onClick={scrollToTop}>Scroll to Top</button>