Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

98
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda