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

176
Views
JS Changing CSS Height Using Variable

I have made a script that takes the height of two elements and if one is smaller than the other, will adjust the height accordingly to match. Going off the console log it is doing and recognising everything as expected except changing the elements height, which I presume is due to it being stored as a variable? Any help appreciated.

console.log('Start of script.');

let divElement = document.getElementById("basic-calendar-card");
let style = window.getComputedStyle(divElement);
let height = style.getPropertyValue("height");

console.log('Basic calendar height = ' + height);

let divElementTwo = document.getElementById("list-calendar-card");
let styleTwo = window.getComputedStyle(divElementTwo);
let heightTwo = styleTwo.getPropertyValue("height");

console.log('List calendar height = ' + heightTwo);

if (height < heightTwo) {
  console.log('List calendar is bigger.')
  divElement.style.height = heightTwo;
} else if (heightTwo < height) {
  console.log('Basic calendar is smaller.')
  divElementTwo.style.height = height;
} else {
  console.log('Same size.')
}

console.log('End of script.');
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!