window scroll to top code example
Example 1: javascript scroll to top of page
//Instant scroll to top of page
window.scrollTo(0, 0);
Example 2: js scrollto
element.scrollTo(x, y);
window.scrollTo(x, y);
element.scrollTo({
top: 100,
left: 100,
behavior: 'smooth'
});