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

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

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 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!