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

144
Vistas
How to collapse a specific section of footer menu after click on mobile

I'm trying to create a responsive footer for mobile so that when users click on one of the titles the elements of that section expand while the other elements of the other remain collapsed and when clicked again it collapses. So far I only manage to create a functionality where after clicking one all element of all expands.

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div>
  <div class="nav-footer">
    <div class="nav">
      <h2 class="title">Legal</h2>
      <ul class="list">
        <li>Privacy Policy</li>
        <li>Terms & Conditions</li>
      </ul>
    </div>
    <div class="nav">
      <h2 class="title">Company</h2>
      <ul class="list">
        <li>About us</li>
        <li>Mission</li>
      </ul>
    </div>
    <div class="nav">
      <h2 class="title">Assistance</h2>
      <ul class="list">
        <li>FAQ</li>
        <li>Contact</li>
      </ul>
    </div>
  </div>
</div>

CSS

.list {
  max-height: 0; 
  overflow:hidden; 
  transition: max-height 1s ease-out;
}

.title {
  cursor: pointer;
}

.test {
  height:auto; 
  max-height: 500px; 
  transition: max-height 0.5s ease-in !important;
}

JS

jQuery(" h2").click(function(){
    $("ul").toggleClass("test");
});

Thank you in advance for your time!

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

0

You can use $(this).next("ul").toggleClass("test"); to find the ul "related" to your h2.

Demo

jQuery(" h2").click(function(){
    $(this).next("ul").toggleClass("test");
});
.list {
  max-height: 0; 
  overflow:hidden; 
  transition: max-height 1s ease-out;
}

.title {
  cursor: pointer;
}

.test {
  height:auto; 
  max-height: 500px; 
  transition: max-height 0.5s ease-in !important;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div>
  <div class="nav-footer">
    <div class="nav">
      <h2 class="title">Legal</h2>
      <ul class="list">
        <li>Privacy Policy</li>
        <li>Terms & Conditions</li>
      </ul>
    </div>
    <div class="nav">
      <h2 class="title">Company</h2>
      <ul class="list">
        <li>About us</li>
        <li>Mission</li>
      </ul>
    </div>
    <div class="nav">
      <h2 class="title">Assistance</h2>
      <ul class="list">
        <li>FAQ</li>
        <li>Contact</li>
      </ul>
    </div>
  </div>
</div>

about 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