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

117
Vistas
Muestre y desplácese a <div> haciendo clic en un enlace específico

Tengo muchos y muchos enlaces a los diferentes divs en la misma página. El div está oculto y, al hacer clic en un enlace, se desplaza a ese div y aparece.

HTML de muestra:

 <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>

Por ejemplo: estoy en la parte inferior de la página y hago clic en uno de esos enlaces, la página se desplaza hasta allí y lo muestra (oculto antes). Por supuesto, diferentes enlaces deberían conducir a diferentes divs.

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

0

Primero agregue Class a todos los párrafos que desee ocultar y establezca display:none css property .

Después de configurar el evento, haga clic en los enlaces, luego obtenga su href (se refiere al párrafo que se mostrará), luego muestre y desplácese hasta este párrafo.

Ver el siguiente fragmento puede ayudarlo a comprender cómo funciona:

 $(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