How to make the page scroll to the top

Scroll the transverse (x-axis) and vertical direction (y-axis), in order to scroll to the top of the page, it is necessary to x and y axes set to 0, the need to use the scroll elements:  el.scrollTop and el.scrollLeft properties.

document.scrollingElement.scrollTop = 0;
document.scrollingElement.scrollLeft = 0;

 

Guess you like

Origin www.cnblogs.com/aisowe/p/11532675.html