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

115
Visualizações
Stop propagation at capture phase & continue on bubble phase

I'm wondering if there's a clean way to control event propagation where I can stop an event from going further down, but bubble back up from there:

    <div className="App">
      <div
        style={{
          background: "black",
          width: "100%",
          height: 400
        }}
        onMouseUp={(e) => {
          alert("outer div");
        }}
      >
        <div
          style={{
            background: "red",
            width: "90%",
            height: 300
          }}
          onMouseUp={(e) => {
            alert("middle div");
          }}
          onMouseUpCapture={(e) => {
            //want to skip inner div but
            //have middle & outer div alerted
          }}
        >
          <div
            style={{
              background: "blue",
              width: "80%",
              height: 150
            }}
            onMouseUp={(e) => {
              alert("inner div");
            }}
          ></div>
        </div>
      </div>
    </div>

Here I want to skip all onClick/onMouseUp events from the middle div but still retain the events that bubble up from the middle div. Is there a way to cleanly achieve this? For context, I am implementing a draggable button that has a react-dom link to it and I can't seem to prevent it from navigating when I let go after dragging.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Use Event.stopPropgation().

stopPropagation('#middle-div', 'mouseup');
function stopPropagation(id, event) {
    $(id).on(event, function(e) {
        alert("middle div");
        e.stopPropagation();
        return false;
    });
}
about 4 years ago · Juan Pablo Isaza Relatório
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