Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

127
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda