Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

116
Vistas
Show and scroll to <div> with click on specific link

I have many and many links to the different divs on the same page. The div is hidden and by clicking on a link it scrolls to that div and shows up.

Sample HTML:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<div id="first_div">
My content with huge text
My content with huge text
My content with huge text
My content with huge text
My content with huge text
My content with huge text
My content with huge text
My content with huge text
My content with huge text
</div>

<p><a href="#first_div">see content with huge text</a></p>

For example: I am at the bottom of the page and click on one of those links, the page scrolls to that and displays it (hidden before). Different links should lead to different divs of course.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

First add Class to all paragraph that you want to hide and set display:none css property .

After set event click on links then get it's href (refers to parag to be shown) , then show and scroll to this paragraph .

See bellow snippet may help you to understand just how it work :

$(document).ready(function(){
   $("a").click(function() {
      if(this.href.split("#")[1]) {
       
        var id= "#"+this.href.split("#")[1];
        
        $(id).fadeIn(2000);
        $('html, body').animate({
            scrollTop: $(id).offset().top
        } , 1000);
        
      }
    });
})
.hidden {
  display:none;
  color:green;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<p><a href="#first_div">see content with huge text</a></p>

<br><br><br><br><br><br><br><br><br><br>
Texts
<br><br><br><br><br><br><br><br><br><br><br><br><br>
Div after will shown up <br><br>
<div class="hidden" id="first_div">
My content with huge text
My content with huge text
My content with huge text
My content with huge text
My content with huge text
My content with huge text
My content with huge text
My content with huge text
My content with huge text
</div>

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda