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

105
Views
Set height of a div dynamically

I try to adjust the height of a div, based on the height of another div. Looks quite simple.. But unfortunately, it does not work. So please give me a hand in this. Here is my code:

   anderblokhoogte = document.getElementById('slider-gaea');
   var curblok = document.getElementById('curiculum');
   curblok.clientHeight = anderblokhoogte.clientHeight + 'px !important';

I proved the element 'slider-gaea' exists, but the clientHeight of 'anderblokhoogte' differs from the height I see when inspecting this element. But also, the adjustment of the curblok.clientHeight does not give a change in height of the target element.

I already tried quite some options (other properties like 'style.height', 'offsetHeight') but no idea what mistake I make.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

anderblokhoogte = document.getElementById('slider-gaea');
var curblok = document.getElementById('curiculum');
document.getElementById('curiculum').style.height = anderblokhoogte.clientHeight + 'px';
<div id="slider-gaea" style="height:100px;"> First Div Block </div>
<div id="curiculum"> Second Div Block</div>

You cannot set height using .clientHeight instead use .style.height and you need to lose the !important at the end as well.

Element.clientHeight is a read-only property.

Note: While HTMLElement.style is also a read-only property, it is possible to set an inline style by assigning a string directly to the style property (see example above).

about 4 years ago · Juan Pablo Isaza Report
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!