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

93
Vistas
The getting height by getBoundingClientRect and offsetHeight issue

I'm trying to get the height of an element after inserting its textContent. The element's height changes as the text is more than 2 lines. The issue is on first click the height I'm getting is wrong, the preceding click is the right height.

// onclick
element.textContent = text

var byOffset = element.offsetHeight;
var byBound = element.getBoundingClientRect();

console.log('by offset height', byOffset);
console.log('by bound height', byBound.height);

on first click

console: by offset height 37
console: by bound height 37

on preceding clicks (preferred output)

console: by offset height 79
console: by bound height 79
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