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

92
Views
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
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!