Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

132
Visualizações
How do I get the scrolling element of current web page?

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!

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

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.

scroller.addEventListener("scroll", event => {
  output.textContent = `scrollBy: ${scroller.scrollBy}`;
});

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

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda