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

197
Views
Bubbling in two children - JS

There is large square and small square that the large square is the top layer. When I click only on the large square I want that the click event of the large square will play. When I click on the small square I want that both of the click events will play.

I don't want to put one div into another.

Thanks in advance :-)

The component:

function App() {
    const clickOnSmall = () => {
        console.log('SMALL')
    }
    const clickOnLarge = () => {
        console.log('LARGE')
    }
    return (
        <div className="App">
            <div className={'small'} onClick={clickOnSmall}></div>
            <div className={'large'} onClick={clickOnLarge}></div>
        </div>
    )
}

The CSS:

.large {
    background: rgba(255, 0, 0, 0.4);
    width: 50%;
    height: 50%;
    position: absolute;
    left: 25%;
    top: 25%;
    z-index: 2;
}

.small {
    background: rgba(0, 255, 0, 0.2);
    width: 30%;
    height: 30%;
    position: absolute;
    left: 35%;
    top: 35%;
    z-index: 1;
}

The browser: browser

There is large square and small square that the large square is the top layer. When I click only on the large square I want that the click event of the large square will play. When I click on the small square I want that both of the click events will play.

I don't want to put one div into another.

Thanks in advance :-)

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!