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

178
Views
Is it possible to trigger an onclick funciton of a child without triggering also its parents?

Hi,

I have this markup:

<div onclick="dothis();">
 <span><img src="icon.png"></span>
 <span>Click here to do this</span>
 <span>some stuff</span>
 <span onclick="close();">X</span>
</div>

the problem is that when I click the X to execute close(); it also executes dothis() which I dont want. I know I could just put the on click on the span containing click here but the thing is that the image and the span below are suppose to execute the function too when clicked and putting an onclick on each one would be redundant. You might say also that I could just wrap the first 3 elements in a new div and put the function there but that would conflict with the function itself (I dont say why because I dont want to drag it out too long).

How can I solve this without having to change the markup?

Thank you.

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