Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

202
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!