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

123
Views
How to exclude child div from being clicked and execute the click on parent instead?

I am trying to make a volume fader, and first what I need to do is to detect the height of the volume fader's container (.volume-control), on which the click happened (the whole thing is vertical).

const setVolume = (e) => {
  let offsetY = Math.round(e.clientY)
  let bottom = Math.round(e.target.getBoundingClientRect().bottom)
  let clickHeight = bottom - offsetY
  console.log((clickHeight / e.target.offsetHeight).toFixed(2))
}
<div class="volume">
  <div id="volume-control" @click="setVolume">
    <div class="volume-fader"></div>
  </div>
</div>

The fader itself is set to 30% height from bottom in css initialy, and the problem is, that when I click on it, I get its offset, and what I need is always the offset of the parent (so that I can set the fader's height respectively to where the click happened). So, how do I exclude the fader from being clicked?

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!