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

195
Vistas
When clicking on a button inside another button, the functions for both buttons are run

I have a button (let's call it main-button) with inside it three divs:

  1. First div containing a poster of a comic
  2. Second div containing info about the comic
  3. Third div containing a button (let's call it collapse-button)

The info-div and collapse-button are hidden by default and shown when the main-button is pressed. This results in the following: you see the poster of a comic and when you click on it, info about it appears below the poster. The collapse-button that appears at the bottom is used to... collapse it back: it hides the second div and itself making the whole contraption go back to it's normal state.

The problem is the following:

When I click on the collapse-button, the event listener for "click" is run and everything collapses. However, for some reason, the event listener of the main-button is also triggered and everything is shown again. A loop. You can show the info but never hide it again.

How can I make sure that when collapse-button is pressed, main-button isn't also triggered?

Thanks!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Inside the "click" function you can stop the propagation of the event so it will not reach the other components
event.stopImmediatePropagation();

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