Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

173
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda