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

153
Views
event.stopPropagation(); prevents own function as well

I have a button inside a whole clickable div and I tried to add event.stopPropagation(); to the end of the button function, but the function itself is also being ignored.

What's wrong about the following code?

var mobileCaptionToggle = document.getElementsByClassName("mobile-caption-toggle");
var b;
for (b = 0; b < mobileCaptionToggle.length; b++) {
  mobileCaptionToggle[b].addEventListener("click", function(event) {
    var mobileCaptionOverlay = this.parentNode.children[0].children[0].children[0].children[0].children[1];
    mobileCaptionOverlay.classList.toggle("visible");
    mobileCaptionOverlay.addEventListener("click", function() {
        mobileCaptionOverlay.classList.toggle("visible");
      }); 

      event.stopPropagation();
  });
}

about 4 years ago · Santiago Gelvez
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!