If the route changes, I want to find the element with scroll on the page I moved and give it window.scrollTo(0,0), how should I find the element?
current code
if (process.client) {
router.afterEach((to, from) => {
document.querySelector('.overflow-scroll').scrollTo(0, 0)
})
}
The code work well but, I don't want use document.querySelector. I want to find scrolling element when route!
Make an event listener and a parameter "scroll" in the event listener write predefined functions or keywords just like scrollX or scrollY You can aslo use bottom or top.
Here is scroll is html class and Id html elements you want to scroll. And output is just show much px you scroll it he is **html class or Id ** you can remove it.
To know or learn in depth.
https://www.w3.org/TR/2016/WD-cssom-view-1-20160317/#dom-element-scrolltop