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

160
Visualizações
Autoscroll page to Anchor under specific conditions

I have an account page with sidebar (in the photo)

enter image description here

I want the page to scroll automatically to #hello anchor in tablet and phone mode so in CSS @media 787

I can't find the appropriate jQuery or how to do it clearly.

I would like a modern and simple method

As I want this jQuery to run only in page account and in @media 787px it may be useful to specify this rule?

if you use a simple clean method, please share

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can check whether the width of the viewport is smaller than 788px, and if so, set location.hash to the hello:

const width = $(window).width();

if(width < 788){
  location.hash = "hello";
}
#hello{
  margin-top:2000px;
  display:block;
}

html{
  scroll-behavior:smooth;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<a id="hello" href="#">Hello World!</a>

about 4 years ago · Juan Pablo Isaza 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